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

📄 viterbidec.m

📁 viterbi译码算法的matlab源代码
💻 M
字号:
function [DecodViterbi] = ViterbiDec(R,y,M)

% R: metrics M-by-M 
% y: vector  M-by-1
% M: The number of the transmit antenner

%__________________________ initialization _______________________________

A = 1.0/sqrt(10);
ConstellationPoint = [3*A+3*A*j  A+3*A*j -3*A+3*A*j -A+3*A*j 3*A+A*j A+A*j  -3*A+A*j -A+A*j  3*A-3*A*j A-3*A*j -3*A-3*A*j -A-3*A*j 3*A-A*j  A-A*j -3*A-A*j -A-A*j];

mn = 16; %the level of the modulation

% initialization
for i = 1:mn
    for tj = 1:M+1
        spath(i,tj).pathmetric = 0;
        spath(i,tj).previous = 0;
    end
end

for i = 2:mn
    spath(i,M+1).pathmetric = 1000000;
end

for i = M:-1:1
    for tj = 1:mn
        t_length = M-i;
        Eur(1:mn) = 0;
        if t_length == 0
            for t = 1:mn
                Eur(t) = R(i,i)*ConstellationPoint(tj);
            end
        else
            for t = 1:mn
                last = t;
                for tp = 1:t_length
                   Eur(t) = Eur(t) + R(i,i+tp)*ConstellationPoint(last);
                   last = spath(last,i+tp).previous;
                end
                Eur(t) = Eur(t) + R(i,i)*ConstellationPoint(tj);
            end
        end
        
        for tem = 1:mn
            Eur_t(tem) = ( y(i)-Eur(tem) ).^2;
        end
        
        for tempv = 1:mn
               tpathmetric(tempv) = spath(tempv,i+1).pathmetric + Eur_t(tempv);
        end
       
        [temppathmetric,I] = min(tpathmetric);
        spath(tj,i).pathmetric = temppathmetric;
        spath(tj,i).previous = I;        
    end
end

for te = 1:mn
    tpathmetric(te) = spath(te,1).pathmetric;
end

[temppathmetric,I] = min(tpathmetric);

% begin to survive
last = I;
DecodViterbi(1) = ConstellationPoint(last);
for i = 1:M-1
    last = spath(last,i).previous;
    DecodViterbi(i+1) = ConstellationPoint(last);
end

⌨️ 快捷键说明

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