⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rayleighawgn.m

📁 To calculation the BER of BPSK over AWGN ang Rayleigh Fading channel.
💻 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 + -