?? 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 + -