?? smldpe54.m
字號:
function [p]=smldPe54(snr_in_dB)
% find the probability of error for the given
% snr_in_dB,signal to noise ratio in dB.
E=1;
SNR=exp(snr_in_dB*log(10)/10); %signal to noise ratio
sgma=E/sqrt(2*SNR); %signal ,standard deviation of noise
N=10000;
% generation of the binary data soure
for i=1:N
temp=rand; %a uniform random variable over (0,1)
if (temp<0.5)
dsource(i)=0; %with probability 1/2,source output is 0
else
dsource(i)=1; %with probability 1/2,source output is 1
end
end;
%detection and probability of error calculation
numoferr=0;
for i=1:N
%matched filter outputs
if (dsource(i)==0)
r0=E+gauss(sgma);
r1=gauss(sgma);
else
r0=gauss(sgma);
r1=E+gauss(sgma);
end;
%detector follows
if (r0>r1)
decis=0;
else
decis=1;
end;
if (decis~=dsource(i))
numoferr=numoferr+1;
end;
end;
p=numoferr/N;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -