% [state_out,output] = ...
%    trellis_fn(state_in,input,trellis_transition,trellis_output)
% Produces next state and output of trellis. state_out is the next
% state (1 through the number of states) and output is the
% corresponding output. state_in is the previous state and input
% is the trellis input. trellis_transition and trellis_output are
% produced by function trellis_init().  
% 
% George Ginis, April 2001

function [state_out,output] = ...
         trellis_fn(state_in,input,trellis_transition,trellis_output)

  % produce next state of trellis
  state_out = trellis_transition(state_in,input+1); 

  % produce trellis output
  output = trellis_output(state_in,input+1);

  % In the above, 1 is added to the input so that the matrix
  % indexing begins at 1 and not at 0. 