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

📄 maxlogmapdec.m

📁 Max Log MAP decoding
💻 M
字号:
function LLRd = MaxLogMAPdec(sig_rec, G, sigma2)
%forward - backward (BCJR) algorithm for non systematic convolutional codes
%sig_rec is a vector of length n0*tau, with rho=1/n0 code rate
%G is the coder matrix
%sigma2 is the noise variance

%decoder parameters
K = size(G, 2);%constraint length
n0 = size(G, 1);%code rate rho=1/n0
M = K-1;%memory length
state_no = pow2(M);
tau = length(sig_rec)/n0;
Yt = reshape(sig_rec, n0, tau)';

%initialisation of alpha(t, m)
alpha = [0 -Inf*ones(1, state_no-1);%t=0
    Inf*ones(tau, state_no)];
%initialisation of beta(t, m)
beta = [Inf*ones(tau, state_no);
    0 -Inf*ones(1, state_no-1)];%t=tau

%compute alpha
for t=1:tau
    %gamma(mp, m)
    for mp=1:state_no
        for m=1:state_no
            [Xt, proba] = trellis(t, mp, m, tau, G);
            if proba==0
                gamma(mp, m) = -Inf;
            else
                gamma(mp, m) = -sum((Yt(t,:) - Xt).^2)/(2*sigma2);
            end 
        end 
    end
    %alpha
    for s=1:state_no
        alpha(t+1,s) = max(alpha(t,:)+(gamma(:,s))');
    end
end

%compute beta
for t=(tau-1):-1:0
    %gamma(mp, m)
    for mp=1:state_no
        for m=1:state_no
            [Xt, proba] = trellis(t+1, mp, m, tau, G);
            if proba==0
                gamma(mp, m) = -Inf;
            else
                gamma(mp, m) = -sum((Yt(t+1,:) - Xt).^2)/(2*sigma2);
            end 
        end 
    end
    %beta
    for s=1:state_no
        beta(t+1,s) = max(beta(t+2,:)+gamma(s,:));
    end 
end 

%logarithm of likelihood ratio for the bits
LLRd = zeros(1, tau);
B = [pow2(M-1):(pow2(M)-1)]+1;%input bit is an 1
A = [0:(pow2(M-1)-1)]+1;%input bit is a 0
for t=1:tau
    LLRd(t) = max(alpha(t+1,B)+beta(t+1,B)) - max(alpha(t+1,A)+beta(t+1,A));
end

⌨️ 快捷键说明

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