% x4 - data setup for data values (-1,1) and time-varying Gauss FIR
% 

if( K == 1)

  G = [];

% set SNR and N before calling x4

  LOADED = 4;

  FIR_save = zeros(FIR_length,N);

  for i=1:N
    FIR_save(:,i) = avg_h + inv_T * (stdev_h * randn(FIR_length,1));
  end

  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

  xt = [zeros(1,Memory), x];

  y = zeros(1,N);

  for i=1:N
    y(i) = xt(i+Memory:-1:i) * FIR_save(:,i);
  end

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

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

  z = y + noise;			% signal plus noise

else	% K > 1

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

  if( LOADED ~= 4)
    error( 'initialize with K = 1 first');
  end

end
