📄 mqam_mpsk.m
字号:
function MQAM_MPSK
% SNR level in dB, notice that this is the snr per bit
% In the calculation of Ps for MQAM, we need to have the average snr per symbol.
SNR = [-6:1:22];
% calculate the theoretical curve
% change the SNR to absolute value
snr_abs = 10.^(SNR ./ 10);
% using Q function
BER_theoretical = q(sqrt(snr_abs));
M = 4;
k = 2;
SER_4QAM_theoretical = 1-(1-2*q(sqrt(3/(M-1) * k * snr_abs))).^2;
M = 16;
k = 4;
SER_16QAM_theoretical =1-(1-2*q(sqrt(3/(M-1) * k * snr_abs))).^2;
M = 64;
k = 6;
SER_64QAM_theoretical = 1-(1-2*q(sqrt(3/(M-1) * k *snr_abs))).^2;
% plot
figure;
plot(SNR, SER_4QAM_theoretical, '-b', SNR, SER_16QAM_theoretical, '-r', SNR, SER_64QAM_theoretical, '-y');
xlabel('SNR');
ylabel('Symbol Error Probability');
set(gca, 'YScale', 'log');
axis([-6 22 10^(-6) 10^(-1)]);
legend('4QAM', '16QAM', '64QAM');
% calculate the upper bound for MPSK
M = 4;
k = 2;
SER_4PSK_theoretical = 2*q(sqrt(2 * k * snr_abs) * sin(pi/M));
M = 16;
k = 4;
SER_16PSK_theoretical = 2*q(sqrt(2 * k * snr_abs) * sin(pi/M));
M = 64;
k = 6;
SER_64PSK_theoretical = 2*q(sqrt(2 * k * snr_abs) * sin(pi/M));
% plot
hold on
plot(SNR, SER_4PSK_theoretical, '--b', SNR, SER_16PSK_theoretical, '--r', SNR, SER_64PSK_theoretical, '--y');
xlabel('SNR');
ylabel('Symbol Error Probability');
set(gca, 'YScale', 'log');
axis([-6 22 10^(-6) 10^(-1)]);
legend('4QAM', '16QAM', '64QAM', '4PSK', '16PSK', '64PSK');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -