📄 mpsk源代码.txt
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -