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

📄 map_decoder.asv

📁 turbo 码matlab编译码程序
💻 ASV
字号:
function [likeli_ratio,extrin_information]=map_decoder(x,x1,CONS,prior_information)
% map algorithm,zero force RSC,in the first interation ,extrinc is zero sequence from decoder 1 to
% decoder 2
K=length(x);
for t=1:K
    for l=1:8                       % l is the trellis numbers
           p_exp(k)=exp(prior_information(k));
           p_1(k)=p_exp(k)/(1+p_exp(k));
           p_0(k)=1/(1+p_exp(k));
           
           [next_state_1,x_p]=nxt_stat1513(l-1,1);
           R_r_1(t,next_state_1+1)=p_1(k)*exp(CONS*((x(t)-1)^2+(x1(t)-(2*x_p-1))^2));
           [next_state_0,x_p]=nxt_stat1513(l-1,0);
           R_r_0(t,next_state_0+1)=p_0(k)*exp(CONS*((x(t)+1)^2+(x1(t)-(2*x_p-1))^2));
                
    end   
end

A_a_initial(1)=1;
A_a_initial(2:8)=0;
    
for t=1:K
    for ll=1:8
            A_a(t,ll)=0;
    end
    A_a_totall(t)=0;
    for ll=1:8
        
            [next_state_0,x_p]=nxt_stat1513(ll-1,0); 
            [next_state_1,x_p]=nxt_stat1513(ll-1,1);
           
            if t==1
                A_a(t,next_state_0+1)=A_a(t,next_state_0+1)+A_a_initial(ll)*R_r_0(t,next_state_0+1);
                A_a(t,next_state_1+1)=A_a(t,next_state_1+1)+A_a_initial(ll)*R_r_1(t,next_state_1+1);
            else
                A_a(t,next_state_0+1)=A_a(t,next_state_0+1)+A_a(t-1,ll)*R_r_0(t,next_state_0+1);
                A_a(t,next_state_1+1)=A_a(t,next_state_1+1)+A_a(t-1,ll)*R_r_1(t,next_state_1+1);

            end
             
    end 
    for ll=1:8
       A_a_totall(t)= A_a_totall(t)+A_a(t,ll);
    end
    for ll=1:8
        A_a(t,ll)=A_a(t,ll)/A_a_totall(t);
    end
end

B_b_K(1)=1;
B_b_K(2:8)=0;
    
for t=K-1:-1:1
    for ll=1:8
            B_b(t,ll)=0;
    end
    for ll=1:8
        
            [next_state_0,x_p]=nxt_stat1513(ll-1,0); 
            [next_state_1,x_p]=nxt_stat1513(ll-1,1);
           
            if t==K-1
                B_b(t,ll)=B_b_K(next_state_0+1)*R_r_0(t+1,next_state_0+1)+B_b_K(next_state_1+1)*R_r_1(t+1,next_state_1+1);
            else
                B_b(t,ll)=B_b(t+1,next_state_0+1)*R_r_0(t+1,next_state_0+1)+B_b(t+1,next_state_1+1)*R_r_1(t+1,next_state_1+1);
            end
             
    end 
    for ll=1:8
        
    end
end

 for t=1:K
     ln_1(t)=0;
     ln_0(t)=0;
     for ll=1:8
         if t==1
             
             [next_state_1,x_p]=nxt_stat1513(ll-1,1);
             ln_1(t)=ln_1(t)+A_a_initial(ll)*R_r_1(t,next_state_1+1)*B_b(t,next_state_1+1);
             [next_state_0,x_p]=nxt_stat1513(ll-1,0);
             ln_0(t)=ln_0(t)+A_a_initial(ll)*R_r_0(t,next_state_0+1)*B_b(t,next_state_0+1);
             
         else if t>1&t<K
             
             [next_state_1,x_p]=nxt_stat1513(ll-1,1);
             ln_1(t)=ln_1(t)+A_a(t-1,ll)*R_r_1(t,next_state_1+1)*B_b(t,next_state_1+1);
             [next_state_0,x_p]=nxt_stat1513(ll-1,0);
             ln_0(t)=ln_0(t)+A_a(t-1,ll)*R_r_0(t,next_state_0+1)*B_b(t,next_state_0+1);
         else
             [next_state_1,x_p]=nxt_stat1513(ll-1,1);
             ln_1(t)=ln_1(t)+A_a(t-1,ll)*R_r_1(t,next_state_1+1)*B_b_K(next_state_1+1);
             [next_state_0,x_p]=nxt_stat1513(ll-1,0);
             ln_0(t)=ln_0(t)+A_a(t-1,ll)*R_r_0(t,next_state_0+1)*B_b_K(next_state_0+1);
           
         end
     end
     
     ln_c(t)=log(ln_1(t)/ln_0(t));
     if ln_c(t)>0
         decision_c(t)=1;
     else
         decision_c(t)=0;
     end
     
 end
end 
likeli_ratio=prior_information+ln_c;
extrin_information=ln_c+4*CONS*x;
% bit_error=0;
% for t=1:K
%     if decision_c(t)~=C_information(t)
%         bit_error=bit_error+1;
%     end
% end

⌨️ 快捷键说明

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