function [ret,x0,str,ts,xts]=multi(t,x,u,flag);
%MULTI	is the M-file description of the SIMULINK system named MULTI.
%	The block-diagram can be displayed by typing: MULTI.
%
%	SYS=MULTI(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 MULTI 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 MULTI with a FLAG of zero:
%	[SIZES]=MULTI([],[],[],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',[10,72,526,386])
     open_system(sys)
end;
set_param(sys,'algorithm',     'Euler')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '999999')
set_param(sys,'Min step size', '0.01')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')
set_param(sys,'Load callback','multidat');
set_param(sys,'AssignWideVectorLines','on');

add_block('built-in/Note',[sys,'/',['Multivariate Lines and  Full State Feedback',13,'(Double click on the "?" for more info)']])
set_param([sys,'/',['Multivariate Lines and  Full State Feedback',13,'(Double click on the "?" for more info)']],...
		'position',[209,225,214,230])


%     Subsystem  'More Info'.

new_system([sys,'/','More Info'])
set_param([sys,'/','More Info'],'Location',[0,0,415,157])

add_block('built-in/Note',[sys,'/',['More Info/This demonstration shows how multivariate lines can be ',13,'used for full state feedback and control of a MIMO system.']])
set_param([sys,'/',['More Info/This demonstration shows how multivariate lines can be ',13,'used for full state feedback and control of a MIMO system.']],...
		'position',[192,25,197,30])

add_block('built-in/Note',[sys,'/',['More Info/Use the signal generators and scopes to observe how ',13,'the system is modeled, or try to improve the controller.']])
set_param([sys,'/',['More Info/Use the signal generators and scopes to observe how ',13,'the system is modeled, or try to improve the controller.']],...
		'position',[191,75,196,80])
set_param([sys,'/','More Info'],...
		'Mask Display','?')


%     Finished composite block 'More Info'.

set_param([sys,'/','More Info'],...
		'hide name',0,...
		'Drop Shadow',4,...
		'position',[355,225,382,250])

add_block('built-in/State-Space',[sys,'/','Plant'])
set_param([sys,'/','Plant'],...
		'A','a',...
		'B','b',...
		'C','c',...
		'D','d',...
		'position',[205,85,290,135])

add_block('built-in/Demux',[sys,'/','demux'])
set_param([sys,'/','demux'],...
		'position',[335,90,385,130])

add_block('built-in/Scope',[sys,'/','Y3'])
set_param([sys,'/','Y3'],...
		'Vgain','10.000000',...
		'Hgain','20.000000',...
		'Vmax','20.000000',...
		'Hmax','40.000000',...
		'Window',[100,100,380,320],...
		'position',[445,130,470,160])

add_block('built-in/Scope',[sys,'/','Y2'])
set_param([sys,'/','Y2'],...
		'Vgain','20.000000',...
		'Hgain','20.000000',...
		'Vmax','40.000000',...
		'Hmax','40.000000',...
		'Window',[0,0,280,220],...
		'position',[445,60,470,90])

add_block('built-in/Scope',[sys,'/','Y1'])
set_param([sys,'/','Y1'],...
		'Vgain','20.000000',...
		'Hgain','20.000000',...
		'Vmax','40.000000',...
		'Hmax','40.000000',...
		'Window',[0,0,280,220],...
		'position',[445,5,470,35])

add_block('built-in/Mux',[sys,'/','mux'])
set_param([sys,'/','mux'],...
		'inputs','3',...
		'position',[90,100,130,130])

add_block('built-in/Signal Generator',[sys,'/','U1'])
set_param([sys,'/','U1'],...
		'Peak','0.491200',...
		'Peak Range','1.000000',...
		'Freq','4.000000',...
		'Freq Range','4.000000',...
		'Wave','Sin',...
		'Units','Rads',...
		'position',[25,23,70,57])

add_block('built-in/Signal Generator',[sys,'/','U2'])
set_param([sys,'/','U2'],...
		'Peak','0.130000',...
		'Peak Range','1.000000',...
		'Freq','6.000000',...
		'Freq Range','6.000000',...
		'Wave','Sin',...
		'Units','Rads',...
		'position',[25,98,70,132])

add_block('built-in/Signal Generator',[sys,'/','U3'])
set_param([sys,'/','U3'],...
		'Peak','0.160000',...
		'Peak Range','1.000000',...
		'Freq','1.000000',...
		'Freq Range','1.000000',...
		'Wave','Sin',...
		'Units','Rads',...
		'position',[25,183,70,217])

add_block('built-in/Sum',[sys,'/','e'])
set_param([sys,'/','e'],...
		'hide name',0,...
		'position',[170,92,185,123])

add_block('built-in/Scope',[sys,'/','Y4'])
set_param([sys,'/','Y4'],...
		'Vgain','10.000000',...
		'Hgain','20.000000',...
		'Vmax','20.000000',...
		'Hmax','40.000000',...
		'Window',[100,100,380,320],...
		'position',[445,185,470,215])

add_block('built-in/State-Space',[sys,'/','Controller'])
set_param([sys,'/','Controller'],...
		'orientation',2,...
		'A','eye(size(a))',...
		'B','ones(size(c''))',...
		'C','ones(size(b''))',...
		'D','zeros(size(d''))',...
		'position',[205,9,290,61])
add_line(sys,[295,110;330,110])
add_line(sys,[310,110;310,35;295,35])
add_line(sys,[200,35;150,35;150,100;165,100])
add_line(sys,[135,115;165,115])
add_line(sys,[190,110;200,110])
add_line(sys,[75,40;85,105])
add_line(sys,[75,115;85,115])
add_line(sys,[75,200;85,125])
add_line(sys,[390,125;400,125;400,200;440,200])
add_line(sys,[390,95;400,95;400,20;440,20])
add_line(sys,[390,115;410,115;410,145;440,145])
add_line(sys,[390,105;410,105;410,75;440,75])

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
end
