function [ret,x0,str]=discrete(t,x,u,flag);
%DISCRETE	is the M-file description of the SIMULINK system named DISCRETE.
%	The block-diagram can be displayed by typing: DISCRETE.
%
%	SYS=DISCRETE(T,X,U,FLAG) returns depending on FLAG certain
%	system values given time point, T, current state vector, X,
%	and input vector, U.
%	FLAG is used to indicate the type of output to be returned in SYS.
%
%	Setting FLAG=1 causes DISCRETE to return state derivitives, FLAG=2
%	discrete states, FLAG=3 system outputs and FLAG=4 next sample
%	time. For more information and other options see SFUNC.
%
%	Calling DISCRETE with a FLAG of zero:
%	[SIZES]=DISCRETE([],[],[],0),  returns a vector, SIZES, which
%	contains the sizes of the state vector and other parameters.
%		SIZES(1) number of states
%		SIZES(2) number of discrete states
%		SIZES(3) number of outputs
%		SIZES(4) number of inputs.
%	For the definition of other parameters in SIZES, see SFUNC.
%	See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.

%	Copyright (c) 1990-94 by The MathWorks, Inc.

% Note: This M-file is only used for saving graphical information;
%       after the model is loaded into memory an internal model
%       representation is used.

% the system will take on the name of this mfile: 
sys = mfilename;
new_system(sys)
simver(1.3)
if(0 == (nargin + nargout))
     set_param(sys,'Location',[64,164,497,489])
     open_system(sys)
end;
set_param(sys,'algorithm',		'Euler')
set_param(sys,'Start time',	'0.0')
set_param(sys,'Stop time',		'999999')
set_param(sys,'Min step size',	'0.0001')
set_param(sys,'Max step size',	'10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',	'')

add_block('built-in/Scope',[sys,'/','Delay Scope'])
set_param([sys,'/','Delay Scope'],...
		'Vgain','10.000000',...
		'Hgain','10.000000',...
		'Vmax','20.000000',...
		'Hmax','20.000000',...
		'Window',[100,100,380,320],...
		'position',[335,47,355,73])

add_block('built-in/Scope',[sys,'/','DSS Scope'])
set_param([sys,'/','DSS Scope'],...
		'Vgain','10.000000',...
		'Hgain','10.000000',...
		'Vmax','20.000000',...
		'Hmax','20.000000',...
		'Window',[100,100,380,320],...
		'position',[335,187,355,213])

add_block('built-in/Discrete State-space',[sys,'/','Dis. State-space'])
set_param([sys,'/','Dis. State-space'],...
		'X0','0',...
		'position',[155,180,275,220])

add_block('built-in/Unit Delay',[sys,'/','Unit Delay'])
set_param([sys,'/','Unit Delay'],...
		'position',[175,50,245,70])

add_block('built-in/Scope',[sys,'/','DZP Scope'])
set_param([sys,'/','DZP Scope'],...
		'Vgain','10.000000',...
		'Hgain','10.000000',...
		'Vmax','20.000000',...
		'Hmax','20.000000',...
		'Window',[100,100,380,320],...
		'position',[335,262,355,288])

add_block('built-in/Scope',[sys,'/','DTF Scope'])
set_param([sys,'/','DTF Scope'],...
		'Vgain','10.000000',...
		'Hgain','10.000000',...
		'Vmax','20.000000',...
		'Hmax','20.000000',...
		'Window',[100,100,380,320],...
		'position',[335,117,355,143])

add_block('built-in/Discrete Zero-Pole',[sys,'/','Dis. Zero-Pole'])
set_param([sys,'/','Dis. Zero-Pole'],...
		'Poles','[0, 1]',...
		'position',[180,250,250,300])

add_block('built-in/Filter',[sys,'/','Discrete Transfer Fcn'])
set_param([sys,'/','Discrete Transfer Fcn'],...
		'Denominator','[1, 2, 1]',...
		'position',[160,105,265,155])

add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
		'Peak','1.000000',...
		'Peak Range','1.000000',...
		'Freq','1.000000',...
		'Freq Range','1.000000',...
		'Wave','Sin',...
		'Units','Rads',...
		'position',[30,148,75,182])

add_block('built-in/Note',[sys,'/','Discrete'])
set_param([sys,'/','Discrete'],...
		'position',[210,0,211,1])

add_block('built-in/Note',[sys,'/','Library'])
set_param([sys,'/','Library'],...
		'position',[210,20,211,21])
add_line(sys,[80,165;115,165;115,130;150,130])
add_line(sys,[80,165;115,165;115,200;145,200])
add_line(sys,[80,165;115,165;115,275;170,275])
add_line(sys,[80,165;115,165;115,60;165,60])
add_line(sys,[255,275;325,275])
add_line(sys,[280,200;325,200])
add_line(sys,[270,130;325,130])
add_line(sys,[250,60;325,60])
% Return any arguments.
if (nargin | nargout)
	% Must use feval here to access system in memory
	if (nargin > 3)
		if (flag == 0)
			eval(['[ret,x0,str]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str] = feval(sys);
	end
end
