• 大小: 3KB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Matlab
  • 标签: polar码  

资源简介

本人写的polar码SC译码算法matlab程序,更多有关polar的资料请关注我的博客

资源截图

代码片段和文件信息

function u=decode(ypolar)
info_position=polar.info_position;
len=polar.code_length;
stage=log2(len);
parm=polar.parm;
F_k=polar.F_k;
sigma=polar.sigma;
h_value=zeros(1len);

%初始化参数
Ly=(2*y)/sigma;
stage_idx=1;
u_b=zeros(1len);
idx=0;
seek_idx=ones(1stage);
%先计算124 f_nodes
    for stage_idx=1:stage
        if stage_idx==1%第一层
            for j=1:len/(2^stage_idx)
                f_value(jstage_idx)=f_node(Ly(j)Ly(j+len/(2^stage_idx)));
            end
            stage_idx=stage_idx+1;
        elseif stage_idx==stage
            for j=1:len/(2^stage_idx)
                f_value(jstage_idx)=f_node(f_value(jstage_idx-1)f_value(j+len/(2^stage_idx)stage_idx-1));
            end
        else
            for j=1:len/(2^stage_idx)
                f_value(jstage_idx)=f_node(f_value(jstage_idx-1)f_value(j+len/(2^stage_idx)stage_idx-1));
            end
            stage_idx=stage_idx+1;
        end
    end
    
    %接下来计算u_b
    while idx        if stage_idx==stage %最后一层
            idx=idx+1;
            h_value(idx)=f_value(1stage_idx);
            if info_position(idx)==0%固定bit
                u_b(idx)=0;
            else
                u_b(idx)=(sign(-h_value(idx))+1)/2;%‘<0‘--->1
            end
            idx=idx+1;%根据idx判断
            if mod(idx+24)==0
                g_value(1stage_idx)=g_node(f_value(1stage_idx-1)f_value(2stage_idx-1)u_b(idx-1));
            end
            
            if mod(idx4)==0
                g_value(1stage_idx)=g_node(g_value(1stage_idx-1)g_value(2stage_idx-1)u_b(idx-1));
            end
            
            h_value(idx)=g_value(1stage_idx);
            
            if info_position(idx)==0%固定bit
                u_b(idx)=0;
            else
                u_b(idx)=(sign(-h_value(idx))+1)/2;
            end
            
            %stage跳转g_node才会跳转,并且会跳到第一层
            stage_idx=stage_idx-parm(idx/2);
            if stage_idx>0
                seek_idx(stage_idx)=seek_idx(stage_idx)+1;
            end
        elseif stage_idx==1 %在第一层,根据parm,计算G_bit反馈与编码结构类似
            G(1:2^(parm(idx/2))stage_idx)=u_b(idx-2^(parm(idx/2))+1:idx)*F_k(1:2^(parm(idx/2))1:2^(parm(idx/2)));
            for ii=1:2^(parm(idx/2))
                if mod(G(iistage_idx)2)==0
                    G_bit(iistage_idx)=0;
                else
                    G_bit(iistage_idx)=1;
                end
            end
            
            for i=1:len/(2^(stage_idx))
                g_value(istage_idx)=g_node(Ly(i)Ly(i+len/(2^(stage_idx)))G_bit(istage_idx));
            end
            stage_idx=stage_idx+1;
            seek_idx(stage_idx)=seek_idx(stage_idx)+1;
        else %中间的层判断是第几次跳转
            
            if mod(seek_idx(stage_idx)2)==0
                G(1:2^(parm(idx/2))stage_idx)=u_b(idx-2^(parm(idx/2))+1:idx)*F_k(1:2^(parm(idx/2))1:2^(parm(idx/2)));
                for ii=1:2^(parm(idx/2))
      

评论

共有 条评论