function [ret,x0,str,ts,xts]=steps(t,x,u,flag);
%STEPS	is the M-file description of the SIMULINK system named STEPS.
%	The block-diagram can be displayed by typing: STEPS.
%
%	SYS=STEPS(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 STEPS 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 STEPS with a FLAG of zero:
%	[SIZES]=STEPS([],[],[],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.

% 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',[23,68,366,351])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '10000')
set_param(sys,'Min step size', '0.001')
set_param(sys,'Max step size', '5')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
		'Peak','1.000000',...
		'Peak Range','5.000000',...
		'Freq','0.500000',...
		'Freq Range','5.000000',...
		'Wave','Sqr',...
		'Units','Rads')
open_system([sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
		'position',[45,33,90,67])

add_block('built-in/Transfer Fcn',[sys,'/',['Second Order',13,'Transfer Fcn']])
set_param([sys,'/',['Second Order',13,'Transfer Fcn']],...
		'Numerator','[w^2]',...
		'Denominator','[1 2*zeta*w w^2]',...
		'Mask Display','Mass-Spring\nDamper System',...
		'Mask Type','Mass-Spring-Damper System')
set_param([sys,'/',['Second Order',13,'Transfer Fcn']],...
		'Mask Dialogue','Mass-Spring-Damper System|Natural Frequency (rad/sec)|Damping',...
		'Mask Translate','w=@1;zeta=@2;')
set_param([sys,'/',['Second Order',13,'Transfer Fcn']],...
		'Mask Help','This block implements the second order transfer function G(s)=num(s)/den(2) where num(s)=w^2 and den(s)=[1 2*zeta*w w^2].',...
		'Mask Entries','2\/0.5\/')
set_param([sys,'/',['Second Order',13,'Transfer Fcn']],...
		'position',[115,20,220,80])


%     Subsystem  ['Integration',13,'Step Size'].

new_system([sys,'/',['Integration',13,'Step Size']])
set_param([sys,'/',['Integration',13,'Step Size']],'Location',[55,255,298,394])

add_block('built-in/Clock',[sys,'/',['Integration',13,'Step Size/Clock']])
set_param([sys,'/',['Integration',13,'Step Size/Clock']],...
		'position',[15,60,35,80])

add_block('built-in/Sum',[sys,'/',['Integration',13,'Step Size/Sum']])
set_param([sys,'/',['Integration',13,'Step Size/Sum']],...
		'inputs','+-',...
		'position',[135,55,155,75])

add_block('built-in/Outport',[sys,'/',['Integration',13,'Step Size/Integration',13,'Step Size']])
set_param([sys,'/',['Integration',13,'Step Size/Integration',13,'Step Size']],...
		'position',[185,55,205,75])

add_block('built-in/Memory',[sys,'/',['Integration',13,'Step Size/Memory']])
set_param([sys,'/',['Integration',13,'Step Size/Memory']],...
		'position',[65,54,100,86])
add_line([sys,'/',['Integration',13,'Step Size']],[105,70;130,70])
add_line([sys,'/',['Integration',13,'Step Size']],[40,70;60,70])
add_line([sys,'/',['Integration',13,'Step Size']],[50,70;50,35;115,35;115,60;130,60])
add_line([sys,'/',['Integration',13,'Step Size']],[160,65;180,65])
set_param([sys,'/',['Integration',13,'Step Size']],...
		'Mask Display','plot(0,0,100,100,[90,69,69,49,49,27,27,10],[74,74,60,60,40,40,80,80],[27,27],[10,30],[49,49],[10,30],[27,49,49,27],[19,19,21,21])')


%     Finished composite block ['Integration',13,'Step Size'].

set_param([sys,'/',['Integration',13,'Step Size']],...
		'position',[85,115,135,155])

add_block('built-in/Note',[sys,'/',['Integration Step Size Demonstration',13,'(Double click on the "?" for more info)']])
set_param([sys,'/',['Integration Step Size Demonstration',13,'(Double click on the "?" for more info)']],...
		'position',[135,195,140,200])


%     Subsystem  'More Info'.

new_system([sys,'/','More Info'])
set_param([sys,'/','More Info'],'Location',[364,69,697,249])

add_block('built-in/Note',[sys,'/',['More Info/This model simulates a second order',13,'mass-spring-damper system. The lower of',13,'the two scope blocks shows the integration',13,'step size of the current integration algorithm.']])
set_param([sys,'/',['More Info/This model simulates a second order',13,'mass-spring-damper system. The lower of',13,'the two scope blocks shows the integration',13,'step size of the current integration algorithm.']],...
		'position',[157,20,162,25])

add_block('built-in/Note',[sys,'/',['More Info/Try changing the natural frequency and damping',13,'of this system. You might also try changing the',13,'integration algorithm (in the "Parameters..." dialog',13,'under the "Simulation" pull-down menu) to see',13,'the effect on integration step size.']])
set_param([sys,'/',['More Info/Try changing the natural frequency and damping',13,'of this system. You might also try changing the',13,'integration algorithm (in the "Parameters..." dialog',13,'under the "Simulation" pull-down menu) to see',13,'the effect on integration step size.']],...
		'position',[165,90,170,95])
set_param([sys,'/','More Info'],...
		'Mask Display','?')


%     Finished composite block 'More Info'.

set_param([sys,'/','More Info'],...
		'hide name',0,...
		'Drop Shadow',4,...
		'position',[285,200,312,225])

add_block('built-in/Scope',[sys,'/','Step Size Scope'])
set_param([sys,'/','Step Size Scope'],...
		'Vgain','2.000000',...
		'Hgain','40.000000',...
		'Vmax','4.000000',...
		'Hmax','80.000000',...
		'Window',[409,392,637,525])
open_system([sys,'/','Step Size Scope'])
set_param([sys,'/','Step Size Scope'],...
		'position',[205,122,225,148])

add_block('built-in/Scope',[sys,'/','Output Scope'])
set_param([sys,'/','Output Scope'],...
		'Vgain','3.000000',...
		'Hgain','40.000000',...
		'Vmax','6.000000',...
		'Hmax','80.000000',...
		'Window',[407,130,636,254])
open_system([sys,'/','Output Scope'])
set_param([sys,'/','Output Scope'],...
		'position',[270,37,290,63])

add_block('built-in/Note',[sys,'/',['To start and stop the simulation, use the "Start//Stop"',13,'selection in the "Simulation" pull-down menu']])
set_param([sys,'/',['To start and stop the simulation, use the "Start//Stop"',13,'selection in the "Simulation" pull-down menu']],...
		'position',[150,240,155,245])
add_line(sys,[95,50;110,50])
add_line(sys,[225,50;265,50])
add_line(sys,[140,135;200,135])

% 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,ts,xts]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str,ts,xts] = feval(sys);
	end
end
