function [ret,x0,str,ts,xts]=example7(t,x,u,flag);
%EXAMPLE7	is the M-file description of the SIMULINK system named EXAMPLE7.
%	The block-diagram can be displayed by typing: EXAMPLE7.
%
%	SYS=EXAMPLE7(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 EXAMPLE7 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 EXAMPLE7 with a FLAG of zero:
%	[SIZES]=EXAMPLE7([],[],[],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',[5,58,704,519])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '50')
set_param(sys,'Min step size', '0.001')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')
set_param(sys,'AssignWideVectorLines','on');

add_block('built-in/Constant',[sys,'/','mu'])
set_param([sys,'/','mu'],...
		'Value','0.2',...
		'position',[20,129,50,161])


%     Subsystem  'Text'.

new_system([sys,'/','Text'])
set_param([sys,'/','Text'],'Location',[181,87,640,471])

add_block('built-in/Note',[sys,'/',['Text/3) the normalization parameter in the Adaptation//Normalizaton',13,'block ']])
set_param([sys,'/',['Text/3) the normalization parameter in the Adaptation//Normalizaton',13,'block ']],...
		'position',[220,260,225,265])

add_block('built-in/Note',[sys,'/',['Text/2) the switching_sigma in the Adaptation//Modification',13,'block']])
set_param([sys,'/',['Text/2) the switching_sigma in the Adaptation//Modification',13,'block']],...
		'position',[190,220,195,225])

add_block('built-in/Note',[sys,'/','Text/1) the adaptive gain in the Adaptation block'])
set_param([sys,'/','Text/1) the adaptive gain in the Adaptation block'],...
		'position',[155,180,160,185])


add_block('built-in/Note',[sys,'/',['Text/To see how the parameters in the adaptive controller',13,'affect the system performance, one can change ']])
set_param([sys,'/',['Text/To see how the parameters in the adaptive controller',13,'affect the system performance, one can change ']],...
		'position',[195,130,200,135])

add_block('built-in/Note',[sys,'/',['Text/To see the effects of unmodeled dynamics on the',13,'adaptive control performance, change mu in the ',13,'contant block marked with mu.',13,' ']])
set_param([sys,'/',['Text/To see the effects of unmodeled dynamics on the',13,'adaptive control performance, change mu in the ',13,'contant block marked with mu.',13,' ']],...
		'position',[190,75,195,80])

add_block('built-in/Note',[sys,'/',['Text/This program simulates the robust model reference',13,'adaptive control scheme discussed in Example 9.3.2.',13,'Please refer to Chapter 9 for more details of the ',13,'problem and algorithm']])
set_param([sys,'/',['Text/This program simulates the robust model reference',13,'adaptive control scheme discussed in Example 9.3.2.',13,'Please refer to Chapter 9 for more details of the ',13,'problem and algorithm']],...
		'position',[190,0,195,5])
set_param([sys,'/','Text'],...
		'Mask Display','Double click here\nfor help to run\nthe simulation')


%     Finished composite block 'Text'.

set_param([sys,'/','Text'],...
		'Drop Shadow',4,...
		'position',[435,302,575,386])

add_block('built-in/To Workspace',[sys,'/','To Workspace'])
set_param([sys,'/','To Workspace'],...
		'mat-name','yout',...
		'position',[550,168,605,192])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'inputs','3',...
		'position',[480,164,510,196])

add_block('built-in/Clock',[sys,'/','Clock'])
set_param([sys,'/','Clock'],...
		'orientation',1,...
		'position',[455,130,475,150])

add_block('built-in/Scope',[sys,'/','y'])
set_param([sys,'/','y'],...
		'Vgain','1.000000',...
		'Hgain','50.000000',...
		'Vmax','2.000000',...
		'Hmax','100.000000',...
		'Window',[864,440,1186,820],...
		'position',[270,65,305,105])


%     Subsystem  'Controller'.

new_system([sys,'/','Controller'])
set_param([sys,'/','Controller'],'Location',[119,140,486,365])

add_block('built-in/Inport',[sys,'/','Controller/y'])
set_param([sys,'/','Controller/y'],...
		'position',[35,27,60,53])

add_block('built-in/Outport',[sys,'/','Controller/u'])
set_param([sys,'/','Controller/u'],...
		'position',[300,62,325,88])

add_block('built-in/Gain',[sys,'/','Controller/Gain'])
set_param([sys,'/','Controller/Gain'],...
		'Gain','-1',...
		'position',[225,59,260,91])

add_block('built-in/Product',[sys,'/','Controller/theta*y'])
set_param([sys,'/','Controller/theta*y'],...
		'position',[130,57,175,88])

add_block('built-in/Inport',[sys,'/','Controller/theta'])
set_param([sys,'/','Controller/theta'],...
		'Port','2',...
		'position',[35,92,60,118])
add_line([sys,'/','Controller'],[180,75;220,75])
add_line([sys,'/','Controller'],[265,75;295,75])
add_line([sys,'/','Controller'],[65,40;105,40;105,65;125,65])
add_line([sys,'/','Controller'],[65,105;105,105;105,80;125,80])
set_param([sys,'/','Controller'],...
		'Mask Display','Controller\nu=-theta*y')


%     Finished composite block 'Controller'.

set_param([sys,'/','Controller'],...
		'orientation',2,...
		'Drop Shadow',4,...
		'position',[130,196,220,254])


%     Subsystem  'Adaptive Law'.

new_system([sys,'/','Adaptive Law'])
set_param([sys,'/','Adaptive Law'],'Location',[47,58,728,479])

add_block('built-in/Product',[sys,'/','Adaptive Law/Product1'])
set_param([sys,'/','Adaptive Law/Product1'],...
		'inputs','3',...
		'position',[305,127,330,163])

add_block('built-in/Sum',[sys,'/','Adaptive Law/Sum2'])
set_param([sys,'/','Adaptive Law/Sum2'],...
		'inputs','-+',...
		'position',[355,122,380,153])


%     Subsystem  'Adaptive Law/Switching_sigma'.

new_system([sys,'/','Adaptive Law/Switching_sigma'])
set_param([sys,'/','Adaptive Law/Switching_sigma'],'Location',[54,130,506,460])

add_block('built-in/Switch',[sys,'/','Adaptive Law/Switching_sigma/switching_sigma'])
set_param([sys,'/','Adaptive Law/Switching_sigma/switching_sigma'],...
		'position',[205,59,245,101])

add_block('built-in/Inport',[sys,'/','Adaptive Law/Switching_sigma/theta'])
set_param([sys,'/','Adaptive Law/Switching_sigma/theta'],...
		'position',[0,64,30,96])

add_block('built-in/Fcn',[sys,'/','Adaptive Law/Switching_sigma/theta_norm'])
set_param([sys,'/','Adaptive Law/Switching_sigma/theta_norm'],...
		'Expr','25-u(1)*u(1)',...
		'position',[75,67,120,93])

add_block('built-in/Constant',[sys,'/','Adaptive Law/Switching_sigma/no_modification'])
set_param([sys,'/','Adaptive Law/Switching_sigma/no_modification'],...
		'Value','0',...
		'position',[80,9,110,41])

add_block('built-in/Fcn',[sys,'/','Adaptive Law/Switching_sigma/sigma_s'])
set_param([sys,'/','Adaptive Law/Switching_sigma/sigma_s'],...
		'Expr','0.2*(u(1)/5-1)',...
		'position',[75,136,120,164])

add_block('built-in/Outport',[sys,'/','Adaptive Law/Switching_sigma/Modification'])
set_param([sys,'/','Adaptive Law/Switching_sigma/Modification'],...
		'position',[390,74,420,106])

add_block('built-in/Product',[sys,'/','Adaptive Law/Switching_sigma/Product2'])
set_param([sys,'/','Adaptive Law/Switching_sigma/Product2'],...
		'position',[310,72,340,108])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[250,80;305,80])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[125,80;200,80])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[345,90;385,90])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[35,80;70,80])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[115,25;170,25;170,65;200,65])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[125,150;170,150;170,95;200,95])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[50,80;50,150;70,150])
add_line([sys,'/','Adaptive Law/Switching_sigma'],[50,150;50,185;270,185;270,100;305,100])
set_param([sys,'/','Adaptive Law/Switching_sigma'],...
		'Mask Display','Modification')


%     Finished composite block 'Adaptive Law/Switching_sigma'.

set_param([sys,'/','Adaptive Law/Switching_sigma'],...
		'orientation',2,...
		'Drop Shadow',4,...
		'position',[390,35,490,95])

add_block('built-in/Inport',[sys,'/','Adaptive Law/y'])
set_param([sys,'/','Adaptive Law/y'],...
		'position',[20,87,45,113])


%     Subsystem  'Adaptive Law/Normalization'.

new_system([sys,'/','Adaptive Law/Normalization'])
set_param([sys,'/','Adaptive Law/Normalization'],'Location',[91,142,551,356])

add_block('built-in/Inport',[sys,'/','Adaptive Law/Normalization/y'])
set_param([sys,'/','Adaptive Law/Normalization/y'],...
		'position',[0,46,25,74])

add_block('built-in/Inport',[sys,'/','Adaptive Law/Normalization/u'])
set_param([sys,'/','Adaptive Law/Normalization/u'],...
		'Port','2',...
		'position',[0,111,25,139])

add_block('built-in/Mux',[sys,'/','Adaptive Law/Normalization/Mux'])
set_param([sys,'/','Adaptive Law/Normalization/Mux'],...
		'inputs','2',...
		'position',[60,81,90,114])

add_block('built-in/Integrator',[sys,'/','Adaptive Law/Normalization/Integrator1'])
set_param([sys,'/','Adaptive Law/Normalization/Integrator1'],...
		'position',[270,92,295,128])

add_block('built-in/Outport',[sys,'/','Adaptive Law/Normalization/1//m'])
set_param([sys,'/','Adaptive Law/Normalization/1//m'],...
		'position',[420,96,445,124])

add_block('built-in/Fcn',[sys,'/','Adaptive Law/Normalization/Fcn1'])
set_param([sys,'/','Adaptive Law/Normalization/Fcn1'],...
		'Expr','1/(1+u(1))',...
		'position',[340,97,395,123])

add_block('built-in/Sum',[sys,'/','Adaptive Law/Normalization/Sum2'])
set_param([sys,'/','Adaptive Law/Normalization/Sum2'],...
		'inputs','+-',...
		'position',[210,92,235,128])

add_block('built-in/Fcn',[sys,'/','Adaptive Law/Normalization/u*u+y*y'])

set_param([sys,'/','Adaptive Law/Normalization/u*u+y*y'],...
		'Expr','u(1)*u(1)+u(2)*u(2)',...
		'position',[125,84,175,116])

add_block('built-in/Gain',[sys,'/','Adaptive Law/Normalization/Gain'])
set_param([sys,'/','Adaptive Law/Normalization/Gain'],...
		'orientation',2,...
		'position',[235,158,270,192])
add_line([sys,'/','Adaptive Law/Normalization'],[180,100;205,100])
add_line([sys,'/','Adaptive Law/Normalization'],[240,110;265,110])
add_line([sys,'/','Adaptive Law/Normalization'],[400,110;415,110])
add_line([sys,'/','Adaptive Law/Normalization'],[300,110;335,110])
add_line([sys,'/','Adaptive Law/Normalization'],[30,60;45,60;55,90])
add_line([sys,'/','Adaptive Law/Normalization'],[30,125;45,125;55,105])
add_line([sys,'/','Adaptive Law/Normalization'],[95,100;120,100])
add_line([sys,'/','Adaptive Law/Normalization'],[315,110;315,175;275,175])
add_line([sys,'/','Adaptive Law/Normalization'],[230,175;185,175;185,120;205,120])
set_param([sys,'/','Adaptive Law/Normalization'],...
		'Mask Display','1/m')


%     Finished composite block 'Adaptive Law/Normalization'.

set_param([sys,'/','Adaptive Law/Normalization'],...
		'Drop Shadow',4,...
		'position',[80,265,160,320])

add_block('built-in/Inport',[sys,'/','Adaptive Law/u'])
set_param([sys,'/','Adaptive Law/u'],...
		'Port','2',...
		'position',[5,177,30,203])

add_block('built-in/Transfer Fcn',[sys,'/','Adaptive Law/filter'])
set_param([sys,'/','Adaptive Law/filter'],...
		'Denominator','[1 2]',...
		'position',[80,172,115,208])

add_block('built-in/Sum',[sys,'/','Adaptive Law/Sum'])
set_param([sys,'/','Adaptive Law/Sum'],...
		'inputs','+-',...
		'position',[155,127,180,158])

add_block('built-in/Transfer Fcn',[sys,'/','Adaptive Law/phi'])
set_param([sys,'/','Adaptive Law/phi'],...
		'Denominator','[1 2]',...
		'position',[140,213,185,247])

add_block('built-in/Note',[sys,'/','Adaptive Law/z'])
set_param([sys,'/','Adaptive Law/z'],...
		'position',[185,125,190,130])

add_block('built-in/Sum',[sys,'/','Adaptive Law/epsilon'])
set_param([sys,'/','Adaptive Law/epsilon'],...
		'inputs','+-',...
		'position',[215,137,245,173])

add_block('built-in/Product',[sys,'/','Adaptive Law/Product'])
set_param([sys,'/','Adaptive Law/Product'],...
		'orientation',2,...
		'position',[230,187,260,218])

add_block('built-in/Outport',[sys,'/','Adaptive Law/theta'])
set_param([sys,'/','Adaptive Law/theta'],...
		'position',[620,126,645,154])

add_block('built-in/Integrator',[sys,'/','Adaptive Law/Integrator'])
set_param([sys,'/','Adaptive Law/Integrator'],...
		'Initial','1',...
		'position',[520,118,550,162])

add_block('built-in/Gain',[sys,'/','Adaptive Law/Adaptive_gain'])
set_param([sys,'/','Adaptive Law/Adaptive_gain'],...
		'position',[430,127,460,153])
add_line([sys,'/','Adaptive Law'],[465,140;515,140])
add_line([sys,'/','Adaptive Law'],[385,140;425,140])
add_line([sys,'/','Adaptive Law'],[120,190;135,190;135,150;150,150])
add_line([sys,'/','Adaptive Law'],[50,100;135,100;135,135;150,135])
add_line([sys,'/','Adaptive Law'],[555,140;615,140])
add_line([sys,'/','Adaptive Law'],[185,145;210,145])
add_line([sys,'/','Adaptive Law'],[165,295;290,295;300,155])
add_line([sys,'/','Adaptive Law'],[335,145;350,145])
add_line([sys,'/','Adaptive Law'],[385,65;340,65;350,130])
add_line([sys,'/','Adaptive Law'],[555,140;585,140;585,65;495,65])
add_line([sys,'/','Adaptive Law'],[60,100;60,280;75,280])
add_line([sys,'/','Adaptive Law'],[35,190;75,190])
add_line([sys,'/','Adaptive Law'],[45,190;45,305;75,305])
add_line([sys,'/','Adaptive Law'],[60,230;135,230])
add_line([sys,'/','Adaptive Law'],[190,230;285,230;285,210;265,210])
add_line([sys,'/','Adaptive Law'],[555,140;585,140;585,195;265,195])
add_line([sys,'/','Adaptive Law'],[225,205;190,205;190,165;210,165])
add_line([sys,'/','Adaptive Law'],[285,210;285,145;300,145])
add_line([sys,'/','Adaptive Law'],[250,155;280,155;280,135;300,135])
set_param([sys,'/','Adaptive Law'],...
		'Mask Display','Adaptation')


%     Finished composite block 'Adaptive Law'.

set_param([sys,'/','Adaptive Law'],...
		'orientation',2,...
		'Drop Shadow',4,...
		'position',[300,154,395,221])


%     Subsystem  'Plant Model'.

new_system([sys,'/','Plant Model'])
set_param([sys,'/','Plant Model'],'Location',[156,93,656,439])


%     Subsystem  'Plant Model/Unmodeled dynamics'.

new_system([sys,'/','Plant Model/Unmodeled dynamics'])
set_param([sys,'/','Plant Model/Unmodeled dynamics'],'Location',[55,75,567,343])

add_block('built-in/Gain',[sys,'/','Plant Model/Unmodeled dynamics/Gain1'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/Gain1'],...
		'Gain','2',...
		'position',[55,64,90,96])

add_block('built-in/Inport',[sys,'/','Plant Model/Unmodeled dynamics/u'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/u'],...
		'position',[5,64,35,96])

add_block('built-in/Sum',[sys,'/','Plant Model/Unmodeled dynamics/Sum2'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/Sum2'],...
		'inputs','+-',...
		'position',[160,72,190,103])

add_block('built-in/Fcn',[sys,'/','Plant Model/Unmodeled dynamics/Fcn'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/Fcn'],...
		'Expr','1/u',...
		'position',[65,172,115,198])

add_block('built-in/Inport',[sys,'/','Plant Model/Unmodeled dynamics/mu'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/mu'],...
		'Port','2',...
		'position',[5,169,35,201])

add_block('built-in/Sum',[sys,'/','Plant Model/Unmodeled dynamics/Sum3'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/Sum3'],...
		'inputs','-+',...
		'position',[380,67,410,98])

add_block('built-in/Outport',[sys,'/','Plant Model/Unmodeled dynamics/u_d'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/u_d'],...
		'position',[460,69,490,101])

add_block('built-in/Product',[sys,'/','Plant Model/Unmodeled dynamics/Product'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/Product'],...
		'position',[240,71,270,104])

add_block('built-in/Integrator',[sys,'/','Plant Model/Unmodeled dynamics/Integrator1'])
set_param([sys,'/','Plant Model/Unmodeled dynamics/Integrator1'],...
		'position',[305,65,340,115])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[95,80;155,80])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[345,90;375,90])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[40,80;50,80])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[415,85;455,85])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[345,90;345,140;145,140;155,95])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[275,90;300,90])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[195,90;215,90;215,80;235,80])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[120,185;220,185;220,95;235,95])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[40,185;60,185])
add_line([sys,'/','Plant Model/Unmodeled dynamics'],[125,80;125,25;350,25;350,75;375,75])
set_param([sys,'/','Plant Model/Unmodeled dynamics'],...
		'Mask Display','-2*mu*s/(1+mu*s)')


%     Finished composite block 'Plant Model/Unmodeled dynamics'.

set_param([sys,'/','Plant Model/Unmodeled dynamics'],...
		'Drop Shadow',4,...
		'position',[115,144,255,206])

add_block('built-in/Sum',[sys,'/','Plant Model/Sum1'])
set_param([sys,'/','Plant Model/Sum1'],...
		'position',[300,154,325,181])


%     Subsystem  'Plant Model/Nominal plant'.

new_system([sys,'/','Plant Model/Nominal plant'])
set_param([sys,'/','Plant Model/Nominal plant'],'Location',[175,229,504,414])

add_block('built-in/Sum',[sys,'/','Plant Model/Nominal plant/Sum'])
set_param([sys,'/','Plant Model/Nominal plant/Sum'],...
		'position',[90,65,110,85])

add_block('built-in/Inport',[sys,'/','Plant Model/Nominal plant/u+u_d'])
set_param([sys,'/','Plant Model/Nominal plant/u+u_d'],...
		'position',[15,60,35,80])

add_block('built-in/Outport',[sys,'/','Plant Model/Nominal plant/y'])
set_param([sys,'/','Plant Model/Nominal plant/y'],...
		'position',[225,65,245,85])

add_block('built-in/Integrator',[sys,'/','Plant Model/Nominal plant/Integrator'])
set_param([sys,'/','Plant Model/Nominal plant/Integrator'],...
		'Initial','1',...
		'position',[150,52,175,98])
add_line([sys,'/','Plant Model/Nominal plant'],[180,75;220,75])
add_line([sys,'/','Plant Model/Nominal plant'],[200,75;200,125;60,125;60,80;85,80])
add_line([sys,'/','Plant Model/Nominal plant'],[115,75;145,75])
add_line([sys,'/','Plant Model/Nominal plant'],[40,70;85,70])
set_param([sys,'/','Plant Model/Nominal plant'],...
		'Mask Display','1/(s-a)')


%     Finished composite block 'Plant Model/Nominal plant'.

set_param([sys,'/','Plant Model/Nominal plant'],...
		'Drop Shadow',4,...
		'position',[345,147,410,193])

add_block('built-in/Outport',[sys,'/','Plant Model/y'])
set_param([sys,'/','Plant Model/y'],...
		'position',[440,157,465,183])

add_block('built-in/Inport',[sys,'/','Plant Model/u'])
set_param([sys,'/','Plant Model/u'],...
		'position',[25,107,50,133])

add_block('built-in/Inport',[sys,'/','Plant Model/mu'])
set_param([sys,'/','Plant Model/mu'],...
		'Port','2',...
		'position',[25,177,50,203])
add_line([sys,'/','Plant Model'],[330,170;340,170])
add_line([sys,'/','Plant Model'],[415,170;435,170])
add_line([sys,'/','Plant Model'],[55,190;110,190])
add_line([sys,'/','Plant Model'],[55,120;265,120;265,160;295,160])
add_line([sys,'/','Plant Model'],[260,175;295,175])
add_line([sys,'/','Plant Model'],[85,120;85,160;110,160])
set_param([sys,'/','Plant Model'],...
		'Mask Display','Plant model')


%     Finished composite block 'Plant Model'.

set_param([sys,'/','Plant Model'],...
		'Drop Shadow',4,...
		'position',[130,100,220,160])
add_line(sys,[515,180;545,180])
add_line(sys,[465,155;475,170])
add_line(sys,[125,225;85,225;85,115;125,115])
add_line(sys,[85,225;85,265;425,265;425,205;400,205])
add_line(sys,[225,130;245,130;245,210;225,210])
add_line(sys,[295,190;285,190;285,240;225,240])
add_line(sys,[55,145;125,145])
add_line(sys,[245,130;425,130;425,170;400,170])
add_line(sys,[425,170;425,180;475,180])
add_line(sys,[425,205;425,190;475,190])
add_line(sys,[245,130;245,85;265,85])

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
