function [ret,x0,str,ts,xts]=suspn(t,x,u,flag);
%SUSPN	is the M-file description of the SIMULINK system named SUSPN.
%	The block-diagram can be displayed by typing: SUSPN.
%
%	SYS=SUSPN(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 SUSPN 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 SUSPN with a FLAG of zero:
%	[SIZES]=SUSPN([],[],[],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
%		SIZES(5) number of roots (currently unsupported)
%		SIZES(6) direct feedthrough flag
%		SIZES(7) number of sample times
%
%	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',[37,61,746,566])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '10')
set_param(sys,'Min step size', '0.001')
set_param(sys,'Max step size', '0.05')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '[t,x]')
set_param(sys,'Load callback','suspdat');


%     Subsystem  'Subsystem2'.

new_system([sys,'/','Subsystem2'])
set_param([sys,'/','Subsystem2'],'Location',[486,613,757,820])
set_param([sys,'/','Subsystem2'],...
		'Mask Display','Double click to\nrun Simulation\n',...
		'Mask Type','Button',...
		'Mask Dialogue','eval(''suspgrph'')')


%     Finished composite block 'Subsystem2'.

set_param([sys,'/','Subsystem2'],...
		'BackGround',5,...
		'hide name',0,...
		'position',[15,450,112,486])

add_block('built-in/Note',[sys,'/',['Developed by David Maclay',13,'Cambridge Control, Ltd.']])
set_param([sys,'/',['Developed by David Maclay',13,'Cambridge Control, Ltd.']],...
		'position',[595,445,600,450])

add_block('built-in/Note',[sys,'/','Vehicle Suspension Model'])
set_param([sys,'/','Vehicle Suspension Model'],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18,...
		'position',[365,15,370,20])

add_block('built-in/Constant',[sys,'/',['acceleration due',13,'to gravity']])
set_param([sys,'/',['acceleration due',13,'to gravity']],...
		'orientation',2,...
		'Value','-9.81',...
		'position',[390,182,440,198])

add_block('built-in/Gain',[sys,'/','1//(Body Inertia)'])
set_param([sys,'/','1//(Body Inertia)'],...
		'Gain','1/Iyy',...
		'position',[290,233,350,267])

add_block('built-in/Integrator',[sys,'/','THETA'])
set_param([sys,'/','THETA'],...
		'position',[495,240,515,260])

add_block('built-in/Gain',[sys,'/','1//(Body Mass)'])
set_param([sys,'/','1//(Body Mass)'],...
		'Gain','1/Mb',...
		'position',[290,123,350,157])

add_block('built-in/Integrator',[sys,'/','Z'])
set_param([sys,'/','Z'],...
		'position',[495,135,515,155])

add_block('built-in/Integrator',[sys,'/','Zdot'])
set_param([sys,'/','Zdot'],...
		'Initial','-1',...
		'position',[440,135,460,155])

add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
		'hide name',0,...
		'position',[395,135,415,155])

add_block('built-in/Integrator',[sys,'/','THETAdot'])
set_param([sys,'/','THETAdot'],...
		'position',[435,240,455,260])


%     Subsystem  'FrontSusp'.

new_system([sys,'/','FrontSusp'])
set_param([sys,'/','FrontSusp'],'Location',[35,42,592,331])

add_block('built-in/Note',[sys,'/','FrontSusp/2*'])
set_param([sys,'/','FrontSusp/2*'],...
		'position',[225,325,230,330])

add_block('built-in/Outport',[sys,'/',['FrontSusp/Vertical',13,'Force']])
set_param([sys,'/',['FrontSusp/Vertical',13,'Force']],...
		'position',[490,80,510,100])

add_block('built-in/Sum',[sys,'/','FrontSusp/Sum2'])
set_param([sys,'/','FrontSusp/Sum2'],...
		'hide name',0,...
		'inputs','+-',...
		'position',[290,119,305,141])

add_block('built-in/Gain',[sys,'/','FrontSusp/damping'])
set_param([sys,'/','FrontSusp/damping'],...
		'Gain','2*cf',...
		'position',[340,107,405,153])

add_block('built-in/Gain',[sys,'/','FrontSusp/MomentArm2'])
set_param([sys,'/','FrontSusp/MomentArm2'],...
		'Gain','Lf',...
		'position',[175,205,235,245])

add_block('built-in/Gain',[sys,'/','FrontSusp/MomentArm1'])
set_param([sys,'/','FrontSusp/MomentArm1'],...
		'Gain','Lf',...
		'position',[175,145,235,185])

add_block('built-in/Inport',[sys,'/',['FrontSusp/Z',13,'Zdot',13,'THETA',13,'THETAdot']])
set_param([sys,'/',['FrontSusp/Z',13,'Zdot',13,'THETA',13,'THETAdot']],...
		'position',[35,125,55,145])

add_block('built-in/Sum',[sys,'/','FrontSusp/Fz'])
set_param([sys,'/','FrontSusp/Fz'],...
		'inputs','--',...
		'position',[440,72,460,108])

add_block('built-in/Sum',[sys,'/','FrontSusp/Sum3'])
set_param([sys,'/','FrontSusp/Sum3'],...
		'hide name',0,...
		'inputs','+-',...
		'position',[290,39,305,61])

add_block('built-in/Demux',[sys,'/','FrontSusp/Demux'])
set_param([sys,'/','FrontSusp/Demux'],...
		'hide name',0,...
		'position',[90,14,135,256])

add_block('built-in/Gain',[sys,'/','FrontSusp/stiffness'])
set_param([sys,'/','FrontSusp/stiffness'],...
		'Gain','2*kf',...
		'position',[340,30,400,70])
add_line([sys,'/','FrontSusp'],[465,90;485,90])
add_line([sys,'/','FrontSusp'],[405,50;420,50;420,80;435,80])
add_line([sys,'/','FrontSusp'],[410,130;420,130;420,100;435,100])
add_line([sys,'/','FrontSusp'],[60,135;85,135])
add_line([sys,'/','FrontSusp'],[310,50;335,50])
add_line([sys,'/','FrontSusp'],[310,130;335,130])
add_line([sys,'/','FrontSusp'],[140,45;285,45])
add_line([sys,'/','FrontSusp'],[140,165;170,165])
add_line([sys,'/','FrontSusp'],[240,165;250,165;250,55;285,55])
add_line([sys,'/','FrontSusp'],[140,225;170,225])
add_line([sys,'/','FrontSusp'],[240,225;260,225;260,135;285,135])
add_line([sys,'/','FrontSusp'],[140,105;225,105;225,125;285,125])


%     Finished composite block 'FrontSusp'.

set_param([sys,'/','FrontSusp'],...
		'hide name',0,...
		'position',[50,86,80,184])


%     Subsystem  'RearSusp'.

new_system([sys,'/','RearSusp'])
set_param([sys,'/','RearSusp'],'Location',[35,42,592,331])

add_block('built-in/Gain',[sys,'/','RearSusp/stiffness'])
set_param([sys,'/','RearSusp/stiffness'],...
		'Gain','2*kr',...
		'position',[340,30,400,70])

add_block('built-in/Demux',[sys,'/','RearSusp/Demux'])
set_param([sys,'/','RearSusp/Demux'],...
		'hide name',0,...
		'position',[90,14,135,256])

add_block('built-in/Sum',[sys,'/','RearSusp/Sum3'])
set_param([sys,'/','RearSusp/Sum3'],...
		'hide name',0,...
		'position',[290,39,305,61])

add_block('built-in/Sum',[sys,'/','RearSusp/Fz'])
set_param([sys,'/','RearSusp/Fz'],...
		'inputs','--',...
		'position',[440,72,460,108])

add_block('built-in/Inport',[sys,'/',['RearSusp/Z',13,'Zdot',13,'THETA',13,'THETAdot']])
set_param([sys,'/',['RearSusp/Z',13,'Zdot',13,'THETA',13,'THETAdot']],...
		'position',[35,125,55,145])

add_block('built-in/Gain',[sys,'/','RearSusp/MomentArm1'])
set_param([sys,'/','RearSusp/MomentArm1'],...
		'Gain','Lr',...
		'position',[175,145,235,185])

add_block('built-in/Gain',[sys,'/','RearSusp/MomentArm2'])
set_param([sys,'/','RearSusp/MomentArm2'],...
		'Gain','Lr',...
		'position',[175,205,235,245])

add_block('built-in/Gain',[sys,'/','RearSusp/damping'])
set_param([sys,'/','RearSusp/damping'],...
		'Gain','2*cr',...
		'position',[340,107,405,153])

add_block('built-in/Sum',[sys,'/','RearSusp/Sum2'])
set_param([sys,'/','RearSusp/Sum2'],...
		'hide name',0,...
		'position',[290,119,305,141])

add_block('built-in/Outport',[sys,'/',['RearSusp/Vertical',13,'Force']])
set_param([sys,'/',['RearSusp/Vertical',13,'Force']],...
		'position',[490,80,510,100])

add_block('built-in/Note',[sys,'/','RearSusp/2*'])
set_param([sys,'/','RearSusp/2*'],...
		'position',[225,325,230,330])
add_line([sys,'/','RearSusp'],[140,105;225,105;225,125;285,125])
add_line([sys,'/','RearSusp'],[240,225;260,225;260,135;285,135])
add_line([sys,'/','RearSusp'],[140,225;170,225])
add_line([sys,'/','RearSusp'],[240,165;250,165;250,55;285,55])
add_line([sys,'/','RearSusp'],[140,165;170,165])
add_line([sys,'/','RearSusp'],[140,45;285,45])
add_line([sys,'/','RearSusp'],[310,130;335,130])
add_line([sys,'/','RearSusp'],[310,50;335,50])
add_line([sys,'/','RearSusp'],[60,135;85,135])
add_line([sys,'/','RearSusp'],[410,130;420,130;420,100;435,100])
add_line([sys,'/','RearSusp'],[405,50;420,50;420,80;435,80])
add_line([sys,'/','RearSusp'],[465,90;485,90])


%     Finished composite block 'RearSusp'.

set_param([sys,'/','RearSusp'],...
		'position',[50,241,80,339])

add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
		'hide name',0,...
		'inputs','-++',...
		'position',[240,232,260,268])

add_block('built-in/Gain',[sys,'/',['Moment',13,'Arm1']])
set_param([sys,'/',['Moment',13,'Arm1']],...
		'Gain','Lf',...
		'position',[175,181,205,219])

add_block('built-in/Gain',[sys,'/',['Moment',13,'Arm2']])
set_param([sys,'/',['Moment',13,'Arm2']],...
		'Gain','Lr',...
		'position',[175,271,205,309])

add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
		'hide name',0,...
		'position',[240,130,260,150])

add_block('built-in/Note',[sys,'/','Front Force'])
set_param([sys,'/','Front Force'],...
		'position',[120,105,138,115])

add_block('built-in/Note',[sys,'/','Rear Force'])
set_param([sys,'/','Rear Force'],...
		'position',[120,290,125,295])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'hide name',0,...
		'position',[625,116,665,329])

add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
		'hide name',0,...
		'position',[580,121,600,154])

add_block('built-in/Step Fcn',[sys,'/',['Road',13,'Height']])
set_param([sys,'/',['Road',13,'Height']],...
		'orientation',2,...
		'ForeGround',4,...
		'Time','7',...
		'After','0.01',...
		'position',[580,70,600,90])

add_block('built-in/To Workspace',[sys,'/','To Workspace1'])
set_param([sys,'/','To Workspace1'],...
		'ForeGround',6,...
		'hide name',0,...
		'mat-name','ForceF',...
		'buffer','[10000 1 0.01]',...
		'position',[225,72,275,88])

add_block('built-in/To Workspace',[sys,'/','To Workspace2'])
set_param([sys,'/','To Workspace2'],...
		'orientation',2,...
		'ForeGround',6,...
		'hide name',0,...
		'mat-name','Zdot',...
		'buffer','[10000 1 0.01]',...
		'position',[340,72,390,88])

add_block('built-in/To Workspace',[sys,'/','To Workspace3'])
set_param([sys,'/','To Workspace3'],...
		'orientation',2,...
		'ForeGround',6,...
		'hide name',0,...
		'mat-name','h',...
		'buffer','[10000 1 0.01]',...
		'position',[490,72,540,88])

add_block('built-in/Step Fcn',[sys,'/',['Moment',13,'due to longitudinal',13,'vehicle acceleration']])
set_param([sys,'/',['Moment',13,'due to longitudinal',13,'vehicle acceleration']],...
		'ForeGround',4,...
		'Time','3',...
		'After','100',...
		'position',[175,355,195,375])

add_block('built-in/To Workspace',[sys,'/','To Workspace4'])
set_param([sys,'/','To Workspace4'],...
		'ForeGround',6,...
		'hide name',0,...
		'mat-name','Y',...
		'buffer','[10000 1 0.01]',...
		'position',[260,357,310,373])

add_block('built-in/To Workspace',[sys,'/','To Workspace5'])
set_param([sys,'/','To Workspace5'],...
		'ForeGround',6,...
		'hide name',0,...
		'mat-name','THETAdot',...
		'buffer','[10000 1 0.01]',...
		'position',[515,324,590,346])
add_line(sys,[385,190;370,190;370,150;390,150])
add_line(sys,[355,140;390,140])
add_line(sys,[420,145;435,145])
add_line(sys,[355,250;430,250])
add_line(sys,[460,250;490,250])
add_line(sys,[465,145;490,145])
add_line(sys,[465,145;475,145;475,195;620,195])
add_line(sys,[520,250;620,250])
add_line(sys,[460,250;480,250;480,305;620,305])
add_line(sys,[670,225;680,225;680,430;15,430;15,290;45,290])
add_line(sys,[670,225;680,225;680,430;15,430;15,135;45,135])
add_line(sys,[210,200;220,200;220,240;235,240])
add_line(sys,[210,290;220,290;220,250;235,250])
add_line(sys,[265,250;285,250])
add_line(sys,[85,135;140,135;140,200;170,200])
add_line(sys,[85,290;170,290])
add_line(sys,[265,140;285,140])
add_line(sys,[85,135;235,135])
add_line(sys,[85,290;120,290;120,145;235,145])
add_line(sys,[520,145;575,145])
add_line(sys,[605,140;620,140])
add_line(sys,[575,80;560,80;560,130;575,130])
add_line(sys,[200,365;225,365;235,260])
add_line(sys,[85,135;185,135;185,80;220,80])
add_line(sys,[575,80;545,80])
add_line(sys,[200,365;255,365])
add_line(sys,[465,145;475,145;475,80;395,80])
add_line(sys,[460,250;480,250;480,335;510,335])

drawnow

% 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
else
	drawnow % Flash up the model and execute load callback
end
