• 大小: 8KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-21
  • 语言: Matlab
  • 标签: Polar  CODES  

资源简介

matlab实现的Polar codes源程序

资源截图

代码片段和文件信息

function TEB=polart2
N_capteurs=4;
N_relais=N_capteurs;
n=N_capteurs*2;

SNR=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
Nb_pk=1000;
G2=[1 0; 1 1];

if n==2
    GG=G2;
elseif n==4
    GG=kron(G2G2);
elseif n==8
    GG=kron(kron(G2G2)G2);
elseif n==16
    GG=kron(kron(kron(G2G2)G2)G2);
elseif n==32
    GG=kron(kron(kron(kron(G2G2)G2)G2)G2);
elseif n==64
    GG=kron(kron(kron(kron(kron(G2G2)G2)G2)G2)G2);
elseif n==128
    GG=kron(kron(kron(kron(kron(kron(G2G2)G2)G2)G2)G2)G2);
elseif n==256
    GG=kron(kron(kron(kron(kron(kron(kron(G2G2)G2)G2)G2)G2)G2)G2);
elseif n==512
    GG=kron(kron(kron(kron(kron(kron(kron(kron(G2G2)G2)G2)G2)G2)G2)G2)G2);
elseif n==1024
    GG=kron(kron(kron(kron(kron(kron(kron(kron(kron(G2G2)G2)G2)G2)G2)G2)G2)G2)G2);
elseif n==2048
    GG=kron(kron(kron(kron(kron(kron(kron(kron(kron(kron(G2G2)G2)G2)G2)G2)G2)G2)G2)G2)G2);
end

bhat=zeros(nn);
bhat(11)=0.5;


for a=2:2:n
    for b=1:n
        if (1<=b) && (b<=a/2)
        bhat(ab)=(2*bhat(a/2b)) - (bhat(a/2b))^2;
        else if ((a/2)+1<=b) && (b<=a)
        
        bhat(ab)=(bhat(a/2b-(a/2)))^2;
        
            else bhat(ab)=0;
          
            end
        
        end
    end   
    
end

bhat=bhat(n:);
bhat;
[val index]=sort(bhat);
lignes=index(1:n/2);
lignes=sort(lignes);
         

  
     G=GG(lignes:);
      
        coding_rate=1/2;

for m=1:size(SNR2)
    for i=1:Nb_pk
  
      
        


        sigma(m) = sqrt(10^(-SNR(:m)/10)*(1/coding_rate));
        % AWGN noise deviation
        u(i:) = (sign(randn(1size(G1)))+1)/2;
      
        
        % random bits
        y(i:) = mod(u(i:)*G2);
       
        % coding
        z(i:) = 2*y(i:)-1;
      channel=(1/sqrt(2))*(randn(1n)+j*randn(1n));
       % channel=randn(1n);
       % channel=ones(1n);
        % BPSK modulation
        zd(i:)=z(i:).*channel;
      % zd(i:)=zd(i:)+ (sigma(m)*randn(1n));
 zd(i:)=zd(i:)+sigma(m)*(1/sqrt(2))*(randn(1size(G2))+j*randn(1size(G2)));
        % AWGN transmission
        ze(i:)=conj(channel).*zd(i:);
   

 L1=4*real(ze(i1))/sigma(m)^2;
 L2=4*real(ze(i2))/sigma(m)^2;
 L3=4*real(ze(i3))/sigma(m)^2;
 L4=4*real(ze(i4))/sigma(m)^2;
 L5=4*real(ze(i5))/sigma(m)^2;
 L6=4*real(ze(i6))/sigma(m)^2;
 L7=4*real(ze(i7))/sigma(m)^2;
 L8=4*real(ze(i8))/sigma(m)^2;


if (L1>709)
    L1=709;
end

if (L2>709)
    L2=709;
end
if (L3>709)
    L3=709;
end
if (L4>709)
    L4=709;
end
if (L5>709)
    L5=709;
end

if (L6>709)
    L6=709;
end
if (L7>709)
    L7=709;
end
if (L8>709)
    L8=709;
end


LLR61=log((exp(L3)+exp(L1))/(1+exp(L3+L1))); 
    
    if (LLR61>0)         
     u6=1;
    else
     u6=0;
    end

 LLR62=log((exp(L7)+exp(L5))/(1+exp(L7+L5))); 
    
     if (LLR62>0)         
     u6=1;
    else
     u6=0;
    end

            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4224  2013-01-12 22:23  polar_codes\test_sam.m

     文件       3954  2013-01-12 22:54  polar_codes\test_sam1.asv

     文件       3940  2013-01-12 22:56  polar_codes\test_sam1.m

     文件       3939  2013-01-12 22:50  polar_codes\test_sam2.m

     文件       4125  2013-01-13 00:08  polar_codes\test_sam3.asv

     文件       4319  2013-01-13 00:16  polar_codes\test_sam3.m

     目录          0  2013-01-13 01:32  polar_codes

----------- ---------  ---------- -----  ----

                24501                    7


评论

共有 条评论