?? rayleighawgn.m
字號:
function [Pe]=RayleighAWGN(snr_in_db)
E=1; %Normalize energy
snr=10^(snr_in_db/10);
sgma=E/sqrt(2*snr); %standard deviation of noise
Num=4000; % The number of binary data
%generation of binary data
for i=1:Num
u=rand;
if(u<=0.5)
data(i)=0;
else
data(i)=1;
end;
end;
%Detection and calculation BER
error=0;
% The correlator outputs
for i=1:Num
if (data(i)==0)
r0=E+GnRayleigh(sgma);
r1=GnRayleigh(sgma);
else
r1=E+GnRayleigh(sgma);
r0=GnRayleigh(sgma);
end
% Detection
if(r0>r1)
result=0;
else
result=1;
end
if(result~=data(i)) %error accumlator
error=error+1;
end
end
Pe=error/Num; %Calculation BER
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -