weixin_44116957
weixin_44116957
2018-12-20 23:36

真萌新自己做了一个matlab仿真,仿真结果的误码率很不理想,跟实际有很大出入,希望大佬帮我看看程序

  • c++
  • c语言
  • 开发语言

clear all
EbNo=0:2:10;
EbNo_lin=10.^(EbNo/10);
M=8
graycode=[0 1 3 2 6 7 5 4];
m=3;

n=7;

k=3;

t=(n-k)/2;

N=1000;

msgj=randint(N,m);
msg=randint(N,k,2^m);

msg1=reshape(msgj.',log2(M),N*(m)/log2(M)).';
msg1_de=bi2de(msg1,'left-msb');

msg1=graycode(msg1_de+1);

msg1=pskmod(msg1,M);

Eb1=norm(msg1).^2/(N*(n-m));

msg0=gf(msg,m);

msg0=rsenc(msg0,n,k).';
msg0=de2bi(double(msg0.x),'left-msb');
y=bi2de(msg0,'left-msb');

msg2=graycode(y+1);
msg2=pskmod(msg2,M);
Eb2=norm(msg2).^2/(N*(m));
for indx=1:length(EbNo_lin)
indx
sigma1=sqrt(Eb1/(2*EbNo_lin(indx)));

rx1=msg1+sigma1*(randn(1,length(msg1))+j*randn(1,length(msg1)));

y1=pskdemod(rx1,M);

y1_de=graycode(y1+1);

[err ber1(indx)]=biterr(msg1_de.',y1_de,log2(M));

sigma2=sqrt(Eb2/(2*EbNo_lin(indx)));    
rx2=msg2+sigma2*(randn(1,length(msg2))+j*randn(1,length(msg2)));    %加入高斯白噪声   
y2=pskdemod(rx2,M);                     
y2=graycode(y2+1);                      
y2=reshape(y2,n,N).';
dec_x=rsdec(gf(y2,3),n,k);
[err ber2(indx)]=biterr(msg,double(dec_x.x),m);        

end
semilogy(EbNo,ber1,'-ko',EbNo,ber2,'-k*');
legend('未编码','RC(7,3)编码')
title('未编码和RC(7.3)编码的8PSK在AWGN下的性能')
xlabel('Eb/No');ylabel('误比特率')
y=reshape(y,n,N).';

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答