% x5 - data setup for Kaleh and Vallet simulation
%

global PS;      % state transition probability matrix
global Xt;      % X(t) vector values
global Nij;     % used to get i and j given n
global IJn;     % used to get n given i and j
global gamma;	% array for forward recursion
global beta;	% array for backward recursion
global LY;	% array for likelihood values

if( K == 1)

  G = [];

  SNR = 10;

  N = 8;		% N data samples

  LOADED = 5;

% set impulse response coefficients for ISI channel
%
  FIR = [0.407 0.815 0.407]';

%%  FIR = [0.4 0.8 0.4]';		
%
%%  FIR = [.227 .460 .688 .460 .227]';
%

  FIR_save = FIR;		% save copy of original FIR

  FIR_length = length(FIR);

  Memory = FIR_length - 1;     % channel memory size

  states = FSM( [-1 1], Memory);

  MM_max = size(states,2);      % number of symbol values

  M = MM_max;			% number of states

  zstate = 1;			% initial state

  x = 2*(rand(1,N) > 0.5) - 1;	% input sequence

  y = FSM_out( x, FIR);		% get FSM output

  var_noise = 10^(-SNR/10) * sum(FIR.*FIR);	% noise variance

  noise = sqrt(var_noise)*randn(1,N);	% random noise

  z = y + noise;			% signal plus noise

% for Viterbi only:
%
%  trans = FSM_trans( states, FIR);

% for Kaleh:
%
   kaleh_init;

else	% K > 1

  error( 'sorry... isi stuff only works with K=1');

end
