📄 cm_sm32.asv
字号:
function[pb,ps]=cm_sm32(snr_in_dB)
N=10000;
E=1;
snr=10^(snr_in_dB/10);
sgma=sqrt(E/(2*snr));
s00=[cos(pi/2) sin(pi/2)];
s01=[cos(pi/2) cos(pi/2)];
for i=1:N,
temp=rand;
if(temp<0.5),
dsource(i)=0;
else
dsource(i)=1;
end;
end;
numofsymbolerror=0;
numofbiterror=0;
for i=1:N,
% n(1)=gngauss(sgma);
% n(2)=gngauss(sgma);
n(1)=sgma*randn(1);
n(2)=sgma*randn(1);
if((dsource(i)==0)),
r=s00+n;
else
r=s01+n;
end;
c00=dot(r , s00);
c01=dot(r , s01);
c_max=max([c00 c01]);
if(c00==c_max)
decis=0;
else
decis=1;
end;
symbolerror=0;
if(decis~=dsource(i)),
numofbiterror=numofbiterror+1;
symbolerror=1;
end;
% if(decis2~=dsource2(i)),
% numofbiterror=numofbiterror+1;
% symbolerror=1;
% end;
if(symbolerror==1),
numofsymbolerror=numofsymbolerror+1;
end;
end;
ps=numofsymbolerror/N;
pb=numofbiterror/(2*N);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -