⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_algorithm.m

📁 LDPC码的编解码Matlab仿真 希望对大家有用
💻 M
字号:
clear all;
close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%% initialize the ldpc parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
data_number=2000;
h=ldpc_generate(data_number,2*data_number,3,2,123);
[H,G]=ldpc_h2g(h,2);
[rows,cols] = size(H);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% begin to test the algorithm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
aver_num=20;

sn=1;

sep_err_data=0;
total_data=0;


for SNR=-0.4:0.2:1.4
    for avernum=1:aver_num;
          data_source=round(rand(1,size(G,1)));
          data_out_ldpc=ldpc_encode(data_source,G,2); 
          
          mod_data=2*data_out_ldpc-1;
        
     
   
%%%%%%%%%%%%%%%%%% pass the signal throuth the AWGN channel %%%%%%%%%%%%%%%%
          sig_power=1;
          alpha=sqrt(sig_power/(10^(SNR/10)));    
          
          channel_output=mod_data+alpha*randn(1,size(G,2));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% obtain the initial soft value of the filter %%%%%%%%%%%%%%%
          L_pri0(1:length(data_out_ldpc))=0.5;
          L_pri1=L_pri0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        
         f1=1./(1+exp(-2*channel_output/alpha^2));        % likelihoods
         f0=1-f1;
         [sep_est_data,success,k] = ldpc_decode(channel_output,f0,f1,H);
         sep_est_source=sep_est_data(size(G,2)+1-size(G,1):size(G,2));
         sep_errnum(avernum)=biterr(sep_est_source',data_source);
         sep_err_data=sep_err_data+sep_errnum(avernum);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    end
    sep_err_snr(sn)=sep_err_data/(total_data*aver_num);
    sn=sn+1;
    
    sep_err_data=0;    
    total_data=0;
end

semilogy(SNR,sep_err_snr);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

haiyan=1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -