mpsk源代码.txt
来自「mpsk的源代码 里面是一个txt文档下载后可以再matlab程序上直接运行」· 文本 代码 · 共 52 行
TXT
52 行
M=8;
% signal noisy ratio
esnodb=1:10;
esno=10.^(esnodb/10);
es=1;
no=10.^(-esnodb/10);
sigma=sqrt(no/2);
for m=1:length(esnodb);
error(m)=0;
s_data(m)=0;
while error(m)<=1000
%input data
da=ceil(rand(1,10000)*M);
% QPSK modulation.
iin=sqrt(es)*cos((2*pi/M)*(da-1));
qin=sqrt(es)*sin((2*pi/M)*(da-1));
%AWGN channel
AWGNi=randn(1,length(da))*sigma(m);
AWGNq=randn(1,length(da))*sigma(m);
% data transmitted throng AWGN channel
ich=iin+AWGNi;
qch=qin+AWGNq;
%distance counter
for i=1:M
d(i,:)=(ich-cos((2*pi/M)*(i-1))).^2+(qch-sin((2*pi/M)*(i-1))).^2;
end
%judge the nearest piont
for j=1:length(qch)
dd(j)=find(d(:,j)==min(d(:,j)));
if dd(j)~=da(j)
error(m)=error(m)+1;
end
end
s_data(m)=s_data(m)+10000;
end
end
% bit error ratio counter
pe=error./s_data;
%display the result
% the result of theory
ps=erfc(sqrt(esno)*sin(pi/M));
semilogy(esnodb,pe,'b * -');hold on;
semilogy(esnodb,ps,'rd-');
xlabel('Es/N0(dB)');ylabel('BER');
legend('the result of simulation','the result of theory');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?