📄 qpsk_system_ber_simulation.m
字号:
% 本程序用来估计 QPSK 误码率;
% 考虑了瑞利衰落和白噪声,没有考虑率多径的影响;
% QPSK System Simulation,Pe evaluation
clear all; % close all;
% echo on;
SNRindB1=0:0.2:5;
SNRindB2=0:0.2:5;
% 瑞利信道;函数 cm_sm32 考虑了瑞利衰落和加性白噪声的影响;
% rayleigh channel
for i=1:length(SNRindB1)
% simulated bit and symbol error rates
[pb,ps]=cm_sm32(SNRindB1(i));
smld_bit_ray_err_prb(i)=pb;
smld_symbol_ray_err_prb(i)=ps;
disp([ps,pb]);
% echo off;
end;
% awgn channel ,函数 cm_sm33 只考虑加性白噪声的影响;
% echo on;
for i=1:length(SNRindB1)
[pb1,ps1]=cm_sm33(SNRindB1(i));
smld_bit_awgn_err_prb(i)=pb1;
smld_symbol_awgn_err_prb(i)=ps1;
disp([ps1,pb1]);
% echo off;
end;
% theory curve
% 理论曲线完全由公式推导得出;
% echo on;
for i=1:length(SNRindB2)
% signal to noise ratio
SNR=exp(SNRindB2(i)*log(10)/10);
% AWGN theoretical bit error rate
theo_err_awgn_prb(i)=0.5*erfc(sqrt(SNR));
% Rayleigh theoretical bit error rate
theo_err_ray_prb(i)=0.5*(1-1/sqrt(1+1/SNR));
% echo off;
end;
echo on;
% Plotting commands follow
figure;
semilogy(SNRindB2,theo_err_awgn_prb,'r');
hold on; grid on;
semilogy(SNRindB1,smld_bit_awgn_err_prb,'rs-.'); hold on;
semilogy(SNRindB2,theo_err_ray_prb); hold on;
semilogy(SNRindB1,smld_bit_ray_err_prb,'b^-.'); hold on;
% semilogy(SNRindB2,0.3,'r*--');
title('BER curves');
xlabel('Eb/No');ylabel('BER');
legend('theory AWGN curve','simulated AWGN curve',...
'theory Rayleigh curve','simulated Rayleigh curve');
echo off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -