我正在尝试实现2x2 MIMO系统无均衡,并且我一直收到错误“Subscripted assignment dimension mismatch”。这是我的matlab代码:
clc; clear; close all;
N = 100;
Eb_No_dB = (-1 : 20);
n_Tx = 2;
n_Rx = 2;
for kk = 1:N
for ii = 1 : length(Eb_No_dB)
% Transmitter
s = rand(2, 1)>0.5; %% generate input bits with equal probabilities
x = 2 * s - 1; %% BPSK Modulation
w = 1/sqrt(2) * (randn(n_Tx,1) + 1i * randn(n_Tx,1)); %% AGWN
h = 1/sqrt(2) * (randn(n_Tx,n_Rx) + 1i * randn(n_Tx,n_Rx)); %% Rayleigh Channel
y = h'*x + 10^(-Eb_No_dB(ii)/20) * w; %% transmitted signal through the channel
h_hat = squeeze(sum(h, 2));
% Receiver
y_out = y./h_hat;
% hard decision decoding
y_r = real(y_out)>0;
n_Error(ii) = size(find((s - y_r), 1));
end
end
Sim_BER = n_Error/N;
Eb_No_Lin = 10.^(Eb_No_dB/10);
BER_Ray_Theory_Rx1 = 0.5 .* (1 - sqrt(Eb_No_Lin./(1 + Eb_No_Lin))); %% BER due to TX1
p = 1/2 - 1/2*(1+1./Eb_No_Lin).^(-1/2);
BER_Ray_Theory_Rx2 = p.^2.*(1+2*(1-p));
semilogy(Eb_No_dB, Sim_BER, 'k*-', 'LineWidth', 2);
hold on;
semilogy(Eb_No_dB, BER_Ray_Theory_Rx1, 'ms-', 'LineWidth', 2);
semilogy(Eb_No_dB, BER_Ray_Theory_Rx2, 'R>-', 'LineWidth', 2);
axis([-1 20 10^-7 1]);
grid on;
xlabel('Eb-No-dB', 'FontSize', 12); ylabel('BER', 'FontSize', 12);
legend('SimulatioN-BER (Rx=Tx=2 WITH ZF)', 'Theory-BER (Tx=Rx=1)', 'Theory-BER(Tx2=1,Rx=2, MRC');
title('BER FOR BPSK MODULATION WITH 2X2 MIMO & ZERO-FORCING EQUALIZER');
答案 0 :(得分:0)