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

📄 vitshort.m

📁 数字通信第四版原书的例程
💻 M
字号:
function out = vitshort(fst_in, snd_in, n_sta, mima);
%VITSHORT makes two steps of transfering expense into one step expense.
%   OUT = VITSHORT(FST_IN SCD_IN, N_STA, MIMA)
%   FST_IN, step one
%   SND_IN, step two
%   N_STA,  number of state
%   MIMA,   ==1 to find the minimum, == 0 to find the maximum
%   OUT, FST_IN, and SND_IN are size 2^n_sta row vectors which recorded the data of
%   [d00, d10, d20, ..., dn0, d01, d11, d21,..., dn1, ...., d0n, d1n, d2n, ...., dnn]
%   where dij means the cost of transfering state i to state j.
%   dij = NaN means that there is no transfering between the two states.
%
%   Used by viterbi.

%       Wes Wang 12/10/95
%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 18:04:53 $

pow_sta = length(fst_in);
for i = 1 : n_sta
    aft_indx = i * n_sta - n_sta;
    for j = 1 : n_sta
        wei_mat = [fst_in(j : n_sta : pow_sta);...
                  snd_in(aft_indx+1 : aft_indx + n_sta)];
        wei_sum = sum(wei_mat);
        wei_indx = find(~isnan(wei_sum));
        if mima
            sub_indx = find(wei_sum == max(sum(wei_mat(:, wei_indx))));
            if length(sub_indx) > 1
                sub_indx = find(wei_mat(1,:) == max(wei_mat(1, sub_indx)));
            end;
        else
            sub_indx = find(wei_sum == min(sum(wei_mat(:, wei_indx))));
            if length(sub_indx) > 1
                sub_indx = find(wei_mat(1,:) == min(wei_mat(1, sub_indx)));
            end;
        end;
        if ~isempty(sub_indx)
            out(aft_indx + j) = wei_sum(sub_indx(1));
        else
            out(aft_indx + j) = NaN;
        end;
    end;
end;

⌨️ 快捷键说明

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