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

📄 viterbi_decoder.asv

📁 CPM调制的线性均衡器
💻 ASV
字号:
function current_state = viterbi_decoder(cpm_param,cpm_low,previous_state)

possible_path.state=zeros(possible_path.number,1);

possible_path.number=(previous_state.number)*(cpm_param.M_ary);

possible_path.weight=zeros(possible_path.number,1);
possible_path.code=zeros((cpm_param.symbols_per_frame),(possible_path.number));

%   List every possible symbol values
Ik=(-cpm_param.M_ary+1):2:(cpm_param.M_ary-1);
Ik=Ik';

imax=previous_state.phasenumber;
jmax=power(cpm_param.M_ary,cpm_param.duration-1);
kmax=cpm_param.M_ary;

%   Generate every possible path
for i=1:imax
    for j=1:jmax
        for k=1:kmax
        index=(i-1)*kmax*jmax+(j-1)*kmax+k;
        start_index=cpm_low.start_index;
        end_index=cpm_low.end_index;
        cpm_state.current_phase=previous_state.phase(i);
        cpm_state.preIk=previous_state.Ik(j);
        cpm_state.Ik=Ik(k);
        [temp_phase_vector,possible_path.phase(index)]=cpm_phase_encoder(cpm_param,cpm_state);
        possible_path.preIk(index)=Ik(k);
        possible_path.code(:,index)=previous_state.code(:,i);
        possible_path.code((previous_state.index),index)=Ik(j);
        possible_path.weight(index)=previous_state.weight((i-1)*max+j)...
            +cpm_low.rx(start_index:end_index)'*cos(temp_phase_vector)...
            +cpm_low.ry(start_index:end_index)'*sin(temp_phase_vector);
        end
    end
end

%   Only one path can survive for each of the same state
current_state.phase=previous_state.phase;
current_state.number=previous_state.number;
current_state.Ik=previous_state.Ik;

near_zero=10^(-5);
for i=1:imax
    cosine_component=cos(current_state.phase(i));
    sine_component=sin(current_state.phase(i));
    for j=1:jmax
        Ik=current_state.Ik(j);
        index=0;
        state_index=(i-1)*jmax+j;
        for k=1:(possible_path.number)
            if ((abs(cos(possible_path.phase(k))-cosine_component)<near_zero) ...
                && (abs(sin(possible_path.phase(k))-sine_component)<near_zero)...
                &&(abs(possible_path.preIk(k)-Ik)<near_zero))
                index=index+1;
                same_state.weight(index)=posssible_path.weight(k);
                same_state.index(index)=j;
            end
        end
        [maxweight,max_index]=max(same_state.weight);
        current_state.weight(state_index)=possible_path.weight(same_state.index(max_index));
        current_state.code(:,state_index)=possible_path.code(:,same_state.index(max_index));
    end
end

⌨️ 快捷键说明

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