www.pudn.com > ctc-matlab.rar > trellis.m, change:2005-03-21,size:1406b


function state_map=trellis 
% function to generate the trellis called state_map here 
% row:input:00 01 10 11 00 01 10 11 ... 
%     state:0           1           ... 
% column:last_state,next_state,output 
% state_map=zeros(32,3); 
% state_map=[0 0 0;6 7 1;1 4 1;7 3 0; 
%            2 4 0;4 3 1;3 0 1;5 7 0 
%            5 1 1;3 6 0;4 5 0;2 2 1; 
%            7 5 1;1 2 0;6 1 0;0 6 1; 
%            1 6 1;7 1 0;0 2 0;6 5 1; 
%            3 2 1;5 5 0;2 6 0;4 1 1; 
%            4 7 0;2 0 1;5 3 1;3 4 0; 
%            6 3 0;0 4 1;7 7 1;1 0 0]; 
 
% last_state(4),next_state(4),last_out(12),next_out(12) 
state_map=zeros(8,32); 
state_map=[0 6 1 7 0 7 4 3 0 0 0 0 1 1 1 0 1 1 1 0 0 0 0 0 1 1 1 0 1 1 1 0; 
           2 4 3 5 4 3 0 7 0 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 1 0; 
           5 3 4 2 1 6 5 2 0 0 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 1 1 1; 
           7 1 6 0 5 2 1 6 0 0 0 0 1 1 1 0 1 1 1 0 0 0 1 0 1 0 1 0 0 1 1 1; 
           1 7 0 6 6 1 2 5 0 0 0 0 1 1 1 0 1 1 1 0 0 0 1 0 1 0 1 0 0 1 1 1; 
           3 5 2 4 2 5 6 1 0 0 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 1 1 1; 
           4 2 5 3 7 0 3 4 0 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 1 0; 
           6 0 7 1 3 4 7 0 0 0 0 0 1 1 1 0 1 1 1 0 0 0 0 0 1 1 1 0 1 1 1 0]; 
%matlab的下标从1开始,因此将前8列的状态值加1 
state_map(:,1:8)=state_map(:,1:8)+1; 
%将后24列的输出值转换成+1/-1形式 
state_map(:,9:end)=state_map(:,9:end)*2-1;