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


%     Subsystem  'Button 5'.

new_system([sys,'/','Button 5'])
set_param([sys,'/','Button 5'],'Location',[-10,380,117,533])
set_param([sys,'/','Button 5'],...
		'Mask Display','Experiment 5',...
		'Mask Dialogue','This Experiment is not Active')


%     Finished composite block 'Button 5'.

set_param([sys,'/','Button 5'],...
		'hide name',0,...
		'position',[180,175,295,245])


%     Subsystem  'Button 2'.

new_system([sys,'/','Button 2'])
set_param([sys,'/','Button 2'],'Location',[131,423,258,576])
set_param([sys,'/','Button 2'],...
		'Mask Display','Magnetic Suspension',...
		'Mask Dialogue','eval(''run_exp2'')')


%     Finished composite block 'Button 2'.

set_param([sys,'/','Button 2'],...
		'hide name',0,...
		'position',[180,85,295,155])


%     Subsystem  'Library2'.

new_system([sys,'/','Library2'])
set_param([sys,'/','Library2'],'Location',[0,56,357,338])


%     Subsystem  'Library2/Button 1'.

new_system([sys,'/','Library2/Button 1'])
set_param([sys,'/','Library2/Button 1'],'Location',[-10,380,117,533])
set_param([sys,'/','Library2/Button 1'],...
		'Mask Display','Sources',...
		'Mask Dialogue','eval(''sources'')')


%     Finished composite block 'Library2/Button 1'.

set_param([sys,'/','Library2/Button 1'],...
		'hide name',0,...
		'position',[35,30,100,80])


%     Subsystem  'Library2/Button 2'.

new_system([sys,'/','Library2/Button 2'])
set_param([sys,'/','Library2/Button 2'],'Location',[-10,380,117,533])
set_param([sys,'/','Library2/Button 2'],...
		'Mask Display','Sinks',...
		'Mask Dialogue','eval(''sinks'')')


%     Finished composite block 'Library2/Button 2'.

set_param([sys,'/','Library2/Button 2'],...
		'hide name',0,...
		'position',[140,30,203,79])


%     Subsystem  'Library2/Button 3'.

new_system([sys,'/','Library2/Button 3'])
set_param([sys,'/','Library2/Button 3'],'Location',[-10,380,117,533])
set_param([sys,'/','Library2/Button 3'],...
		'Mask Display','Linear\nBlocks',...
		'Mask Dialogue','eval(''linear'')')


%     Finished composite block 'Library2/Button 3'.

set_param([sys,'/','Library2/Button 3'],...
		'hide name',0,...
		'position',[240,30,304,80])


%     Subsystem  'Library2/Button 6'.

new_system([sys,'/','Library2/Button 6'])
set_param([sys,'/','Library2/Button 6'],'Location',[-10,380,117,533])
set_param([sys,'/','Library2/Button 6'],...
		'Mask Display','Ports',...
		'Mask Dialogue','eval(''portdemo'')')


%     Finished composite block 'Library2/Button 6'.

set_param([sys,'/','Library2/Button 6'],...
		'hide name',0,...
		'position',[240,155,302,207])


%     Subsystem  'Library2/Button 5'.

new_system([sys,'/','Library2/Button 5'])
set_param([sys,'/','Library2/Button 5'],'Location',[-10,380,117,533])
set_param([sys,'/','Library2/Button 5'],...
		'Mask Display','Discrete\nBlocks',...
		'Mask Dialogue','eval(''discrete'')')


%     Finished composite block 'Library2/Button 5'.

set_param([sys,'/','Library2/Button 5'],...
		'hide name',0,...
		'position',[140,155,203,208])


%     Subsystem  'Library2/Button 4'.

new_system([sys,'/','Library2/Button 4'])
set_param([sys,'/','Library2/Button 4'],'Location',[-10,380,117,533])
set_param([sys,'/','Library2/Button 4'],...
		'Mask Display','Nonlinear\nBlocks',...
		'Mask Dialogue','eval(''nonlin'')')


%     Finished composite block 'Library2/Button 4'.

set_param([sys,'/','Library2/Button 4'],...
		'hide name',0,...
		'position',[35,155,101,208])

add_block('built-in/Note',[sys,'/',['Library2/Double click on any of ',13,'these blocks to see the ',13,'demo of your choice']])
set_param([sys,'/',['Library2/Double click on any of ',13,'these blocks to see the ',13,'demo of your choice']],...
		'position',[175,90,180,95])
set_param([sys,'/','Library2'],...
		'Mask Display','Inverted Pendulum',...
		'Mask Dialogue','eval(''run_exp1'')')


%     Finished composite block 'Library2'.

set_param([sys,'/','Library2'],...
		'BackGround',4,...
		'hide name',0,...
		'Drop Shadow',4,...
		'position',[45,85,160,155])


%     Subsystem  'Button 4'.

new_system([sys,'/','Button 4'])
set_param([sys,'/','Button 4'],'Location',[-10,380,117,533])
set_param([sys,'/','Button 4'],...
		'Mask Display','Experiment 4',...
		'Mask Dialogue','This Experiment is not Active')


%     Finished composite block 'Button 4'.

set_param([sys,'/','Button 4'],...
		'hide name',0,...
		'position',[45,175,160,245])

add_block('built-in/Note',[sys,'/','Virtual Process Laboratory'])
set_param([sys,'/','Virtual Process Laboratory'],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18,...
		'position',[250,20,255,25])

add_block('built-in/Note',[sys,'/','Double click on any of these blocks to run the simulation'])
set_param([sys,'/','Double click on any of these blocks to run the simulation'],...
		'position',[240,255,245,260])


%     Subsystem  'Button 3'.

new_system([sys,'/','Button 3'])
set_param([sys,'/','Button 3'],'Location',[-10,380,117,533])
set_param([sys,'/','Button 3'],...
		'Mask Display','Temperatur Control',...
		'Mask Dialogue','eval(''run_exp3'')')


%     Finished composite block 'Button 3'.

set_param([sys,'/','Button 3'],...
		'hide name',0,...
		'position',[315,85,430,155])


%     Subsystem  'Library1'.

new_system([sys,'/','Library1'])
set_param([sys,'/','Library1'],'Location',[0,56,357,338])

add_block('built-in/Note',[sys,'/',['Library1/Double click on any of ',13,'these blocks to see the ',13,'demo of your choice']])
set_param([sys,'/',['Library1/Double click on any of ',13,'these blocks to see the ',13,'demo of your choice']],...
		'position',[175,90,180,95])


%     Subsystem  'Library1/Button 4'.

new_system([sys,'/','Library1/Button 4'])
set_param([sys,'/','Library1/Button 4'],'Location',[-10,380,117,533])
set_param([sys,'/','Library1/Button 4'],...
		'Mask Display','Nonlinear\nBlocks',...
		'Mask Dialogue','eval(''nonlin'')')


%     Finished composite block 'Library1/Button 4'.

set_param([sys,'/','Library1/Button 4'],...
		'hide name',0,...
		'position',[35,155,101,208])


%     Subsystem  'Library1/Button 5'.

new_system([sys,'/','Library1/Button 5'])
set_param([sys,'/','Library1/Button 5'],'Location',[-10,380,117,533])
set_param([sys,'/','Library1/Button 5'],...
		'Mask Display','Discrete\nBlocks',...
		'Mask Dialogue','eval(''discrete'')')


%     Finished composite block 'Library1/Button 5'.

set_param([sys,'/','Library1/Button 5'],...
		'hide name',0,...
		'position',[140,155,203,208])


%     Subsystem  'Library1/Button 6'.

new_system([sys,'/','Library1/Button 6'])
set_param([sys,'/','Library1/Button 6'],'Location',[-10,380,117,533])
set_param([sys,'/','Library1/Button 6'],...
		'Mask Display','Ports',...
		'Mask Dialogue','eval(''portdemo'')')


%     Finished composite block 'Library1/Button 6'.

set_param([sys,'/','Library1/Button 6'],...
		'hide name',0,...
		'position',[240,155,302,207])


%     Subsystem  'Library1/Button 3'.

new_system([sys,'/','Library1/Button 3'])
set_param([sys,'/','Library1/Button 3'],'Location',[-10,380,117,533])
set_param([sys,'/','Library1/Button 3'],...
		'Mask Display','Linear\nBlocks',...
		'Mask Dialogue','eval(''linear'')')


%     Finished composite block 'Library1/Button 3'.

set_param([sys,'/','Library1/Button 3'],...
		'hide name',0,...
		'position',[240,30,304,80])


%     Subsystem  'Library1/Button 2'.

new_system([sys,'/','Library1/Button 2'])
set_param([sys,'/','Library1/Button 2'],'Location',[-10,380,117,533])
set_param([sys,'/','Library1/Button 2'],...
		'Mask Display','Sinks',...
		'Mask Dialogue','eval(''sinks'')')


%     Finished composite block 'Library1/Button 2'.

set_param([sys,'/','Library1/Button 2'],...
		'hide name',0,...
		'position',[140,30,203,79])


%     Subsystem  'Library1/Button 1'.

new_system([sys,'/','Library1/Button 1'])
set_param([sys,'/','Library1/Button 1'],'Location',[-10,380,117,533])
set_param([sys,'/','Library1/Button 1'],...
		'Mask Display','Sources',...
		'Mask Dialogue','eval(''sources'')')


%     Finished composite block 'Library1/Button 1'.

set_param([sys,'/','Library1/Button 1'],...
		'hide name',0,...
		'position',[35,30,100,80])
set_param([sys,'/','Library1'],...
		'Mask Display','Experiment 6',...
		'Mask Dialogue','This Experiment is not Active')


%     Finished composite block 'Library1'.

set_param([sys,'/','Library1'],...
		'hide name',0,...
		'position',[315,175,430,245])

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
