?? cm_bpske.m
字號:
function[p]=cm_bpske(snr_in_db)
% [p]=cm_bpske(snr_in_db)
% cm_bpske finds the probability of error for the given value of snr_in_db
N=5000;
E=1; %energy per symbol
snr=10^(snr_in_db/10); %signal to noise ratio
sgma=E/sqrt(snr*2); %noise variance
%generation of data source
for i=1:N
temp=rand;
if(temp<0.5)
dsource(i)=0;
else
dsource(i)=1;
end
end
%detection and the probability of errror calculation
numofbiterror=0;
for i=1:N
%received signal at the detector ,for the ith symbol is:
if (dsource(i)==0)
r0=E+gngauss(sgma);
r1=gngauss(sgma);
else
r1=E+gngauss(sgma);
r0=gngauss(sgma);
end
% the detector is:
if(r0>r1)
decis=0;
else
decis=1;
end
%increment the error counter,if the decision is not correct
if (decis~=dsource(i))
numofbiterror=numofbiterror+1;
end
end
p=numofbiterror/N;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -