首页 > 其他分享 >RS+BCH级联编译码误码率性能matlab仿真

RS+BCH级联编译码误码率性能matlab仿真

时间:2023-01-15 20:15:31浏览次数:50  
标签:误码率 级联 end err RS double Msg BCH

1.算法描述

        在实际情况中,在光通信信道中出现的错误有单独随机出现的误码,也有突发出现的无码,为了更好的提升光通信的性能,需要使用级联码。

 

        级联码在进行编码的时候,将k1k2个二进制bit数据分为k2个部分,每个部分由k1个bit信息,然后按照非二进制分组码编成(n2,k2)的外码C2,最小距离为d2,码率为R2= k2/n2。然后将每一个部分中的k1个信息按照二进制分组码编码成(n1,k1)的内码C1,最小距离为d1,码率为R1=k1/n1。因此,级联码的码率为R = R1R2。

 

        级联码根据结构的不同,可以分为内外型级联码,并行型级联码以及交织连续型级联码三种类型,根据文献[50]的研究成果,我们选择一种结构较为简单的内外型级联码作为本文的一个研究对象。

 

        在本课题中,本文选择内外型级联码的内码分别为BCH(15,7)和BCH(255,207),外码使用RS(31,15)两种类型进行仿真性能分析。级联码的基本结构框图如下图所示:

 

2.仿真效果预览

matlab2013b仿真结果如下:

 

       从上面的仿真分析可知,RS(31,15)+BCH(15,7)这种内外型级联码具有良好的纠错性能,当SNR = 5的时候,其误码率性能达到了10^-5。

 

3.MATLAB部分代码预览

 

%参数初始化
k            = 15;       
n            = 31;   
 
N            = 15; 
K            = 7; 
 
Len          = log2(n+1);
Simu_Len     = k;  %仿真的时间长度
Simu_time    = 1;
SNR          = [0:1:5];
TJL          = [200,150,100,50];
 
 
Rs_Encoder   = fec.rsenc(n,k);
Rs_Decoder   = fec.rsdec(Rs_Encoder);
 
%主体代码
for i = 1:length(SNR)
    i
    Bit_err(i)    = 0; %设置误码率参数
    Num_err       = 0; %蒙特卡洛模拟次数
    Numbers       = 0; %误码率累加器
    while Num_err <= TJL 
          fprintf('Eb/N0 = %f\n', SNR(i));
          Num_err 
          %产生信号
          msg2     = (double(rand(1,Simu_Len)>0.5))';
          %编码
          Msg_Enc  = encode(Rs_Encoder,msg2);
          %转换为二进制
          Msg_Enc2 = func_dec2bin(Msg_Enc,Len);
 
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          
          message    = [Msg_Enc2,(rand(1,55)>=0.5)];
          Rec        = [];
          for jj = 1:length(message)/K
              tmps       = message((jj-1)*K+1:jj*K);
              msg        = gf(tmps);
              BCHcode_gf = bchenc(msg,N,K);
              %BCH编码
              BCHcode_double=-1*ones(1,N);
              for code_j=1:N
                  if BCHcode_gf(1,code_j)==1
                     BCHcode_double(1,code_j)=1;
                  end
              end         
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %通过信道
              BCH_receive = awgn(BCHcode_double,SNR(i),'measured');
 
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              hard_coded  = zeros(1,N);
              for hard_j=1:N
                  if BCH_receive(hard_j)>0
                     hard_coded(hard_j)=1;
                  end
              end
              %BCH解码 
              BCHdecode = gf(zeros(1,K));
              hard_BCH  = hard_coded;
              [BCHdecode_i,error_num]=bchdec(gf(hard_BCH),N, K);
              BCHdecode = BCHdecode_i;
              BCHdecode_double = zeros(1,K);
 
              for gf_to_double_j=1:K
                  if BCHdecode(gf_to_double_j)==1
                     BCHdecode_double(gf_to_double_j)=1;
                  end
              end
              Msg_Enc4 = BCHdecode_double;
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              Rec = [Rec,Msg_Enc4];
          end
          Rec(end-55+1:end) = [];
          
          %二进制转换为十进制
          Msg_Enc5 = Rec; 
          Msg_Enc6 = func_bin2dec(Msg_Enc5,Len);
        
          %译码
          [Msg_Dec,cnumerr,ccode] = decode(Rs_Decoder,Msg_Enc6');
          %计算误码率
          Err                     = biterr(Msg_Dec,msg2);
          Num_err                 = Num_err+Err;
          Num_err
          Numbers                 = Numbers+1;
    end  
    Bit_err(i) = Num_err/(Simu_Len*Numbers);  
end
 
%曲线仿真
figure;
semilogy(SNR,Bit_err,'b-o');
xlabel('SNR');
ylabel('BER');
grid on;
save data.mat SNR Bit_err
A_046

 

  

 

标签:误码率,级联,end,err,RS,double,Msg,BCH
From: https://www.cnblogs.com/51matlab/p/17054012.html

相关文章