function [output]=SYS2(xdata, time)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% function [output]=SYS2(xdata, time)
%%
%% Creators Kittiphan Techakittiroj
%%          Thaveesak Krisornsuthasinee
%%          Yujira Jirapinyo
%% Created  17 April 1996 (at ESCI, Case Western Reserve University)
%% Modified 29 April 1996 (at ESCI, Case Western Reserve University)
%% MATLAB   version 4.2c (it should work with the lower version also because
%%          there is no special command)
%%
%% Example of Discrete Time Invariant System
%%
%% Input:  xdata      The input to the system
%%         time       The current time
%% Output: output     The output from the system
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  if nargin~=2
      error('incorrect number of parameters, refer to "help SYS2".');
    end;

  global GLOBAL_SYS2_INPUT GLOBAL_SYS2_STATE;

  uu = GLOBAL_SYS2_INPUT;
  if length(uu) < 1;
    uu = zeros(1,1);
    end;
  xx = GLOBAL_SYS2_STATE;
  if length(xx) < 1;
    xx = zeros(1,1);
    end;

  x  = 0.9*xx(1) + 1*xdata + 2*uu(1);
  uu = [xdata uu(1:length(uu)-1)];
  xx = [x xx(1:length(xx)-1)];

  GLOBAL_SYS2_INPUT = uu;
  GLOBAL_SYS2_STATE = xx;
  output = x;
