我想模拟 AWGN 通道的 QPSK,并将我得到的错误与图上的理论错误进行比较。我想在 MATLAB 上针对从 1 到 10 的不同 SNR 值执行此操作。当我绘制此图时,我得到模拟误差和理论误差之间的巨大差异。我怀疑我可能已经完成了解调部分。我在那里使用了 atan 函数,但我不确定它是否有效。你能帮助我吗?
M=100000;
snrdB=1:10;
snr=10.^(snrdB/10);
sError = zeros(1,10);%simulated error
tError = zeros(1,10);%theoritical error
for i=1:10
symbols = randi([1,4],1,M);
symbols(symbols == 1) = 1;
symbols(symbols == 2) = 1i;
symbols(symbols == 3) = -1;
symbols(symbols == 4) = -1i;
%calculating total energy
Eb = 0;
for k=1:M
Eb = Eb + abs(symbols(k).^2);
end
Eb = Eb/2;
var = abs(sqrt(Eb/(2*snr(i))));%variance
noise = var*rand(1,M) + var*1i*rand(1,M);%noise
r=symbols+noise;%adding noise
symbols1 = atan(r);%demodulation
error = abs((symbols - symbols1)./abs(symbols));%error
sError(i) = mean(error);
tError(i) = 2*qfunc(sqrt(2*snr(i)));%theoritical error
end
%comparison
semilogy(snrdB, tError,'x-')
hold on
semilogy(snrdB, sError,'o-')
xlabel('snr(dB)')
ylabel('error')
grid on