function [ret,x0,str]=simosys(t,x,u,flag);
%SIMOSYS	is the M-file description of the SIMULINK system named SIMOSYS.
%	The block-diagram can be displayed by typing: SIMOSYS.
%
%	SYS=SIMOSYS(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 SIMOSYS to return state derivatives, FLAG=2
%	discrete states, FLAG=3 system outputs and FLAG=4 next sample
%	time. For more information and other options see SFUNC.
%
%	Calling SIMOSYS with a FLAG of zero:
%	[SIZES]=SIMOSYS([],[],[],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',[0,0,390,193])
     open_system(sys)
end;
set_param(sys,'algorithm',		'RK-45')
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/S-function',[sys,'/','S-function'])
set_param([sys,'/','S-function'],...
		'function name','simom',...
		'parameters','',...
		'position',[130,43,215,77])

add_block('built-in/Demux',[sys,'/','Demux'])
set_param([sys,'/','Demux'],...
		'outputs','2',...
		'position',[235,39,275,81])

add_block('built-in/Outport',[sys,'/','Outport1'])
set_param([sys,'/','Outport1'],...
		'Port','2',...
		'position',[310,90,330,110])

add_block('built-in/Outport',[sys,'/','Outport'])
set_param([sys,'/','Outport'],...
		'Port','1',...
		'position',[310,15,330,35])

add_block('built-in/Inport',[sys,'/','Inport'])
set_param([sys,'/','Inport'],...
		'Port','1',...
		'position',[45,50,65,70])

add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
		'Vgain','10.000000',...
		'Hgain','20.000000',...
		'Vmax','20.000000',...
		'Hmax','40.000000',...
		'Window',[100,100,380,320],...
		'position',[275,135,300,165])
add_line(sys,[280,70;290,70;290,100;305,100])
add_line(sys,[280,50;290,50;290,25;305,25])
add_line(sys,[220,60;230,60])
add_line(sys,[220,60;270,150])
add_line(sys,[70,60;125,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,xstr]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str] = feval(sys);
	end
end
