main.m

来自「关于低密度奇偶校验码的生成」· M 代码 · 共 24 行

M
24
字号
 function  main     
         sigma = 1;                          % AWGN noise deviation
         q = 4;                              % Field parameter
         nbits = log2(q);                    % bits per symbol
         rows=15;
         cols=20;
         h = gen_ldpc(rows,cols);                % Generate H
         [H,G] = ldpc_h2g(h,q);              % find systematic G and modify H
         x = floor(rand(1,size(G,1))*q);     % random symbols
         y = ldpc_encode(x,G,q);             % encoding 
         yb = (fliplr(de2bi(y,nbits)))';     % convert total index to binary format
         yb = yb(:);                         % make a vector
         zb = 2*yb-1;                        % BPSK modulation
         zb=zb + sigma*randn(size(zb));      % AWGN transmission

         f1=1./(1+exp(-2*zb/sigma^2));        % likelihoods for bits
         f1 = f1(:);                         % make it a vector
         f1 = reshape(f1,nbits,length(y));   % reshape for finding priors on symbols                    
         f0=1-f1;
         junk = ones(q,length(y));           % this is a placeholder in the next function
         [v0, v1, pp] = bits_smbl_msg(f0,f1,junk);
         [z_hat, success, k] = ldpc_decode(pp,H,q);
         x_hat = z_hat(size(G,2)+1-size(G,1):size(G,2));
         x_hat = x_hat'; 

⌨️ 快捷键说明

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