function [ret,x0,str,ts,xts]=simulink(t,x,u,flag);
%SIMULINK	is the M-file description of the SIMULINK system named SIMULINK.
%	The block-diagram can be displayed by typing: SIMULINK.
%
%	SYS=SIMULINK(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 SIMULINK 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 SIMULINK with a FLAG of zero:
%	[SIZES]=SIMULINK([],[],[],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',[19,60,486,181])
     open_system(sys)
end;
set_param(sys,'algorithm',     'Euler')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '1')
set_param(sys,'Min step size', '0.1')
set_param(sys,'Max step size', '0.1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')


%     Subsystem  'Linear'.

new_system([sys,'/','Linear'])
set_param([sys,'/','Linear'],'Location',[160,253,354,586])

add_block('built-in/Note',[sys,'/','Linear/Linear Library'])
set_param([sys,'/','Linear/Linear Library'],...
		'position',[100,5,105,10])


%     Subsystem  ['Linear/Inner',13,'Product'].

new_system([sys,'/',['Linear/Inner',13,'Product']])
set_param([sys,'/',['Linear/Inner',13,'Product']],'Location',[33,479,253,634])

add_block('built-in/Inport',[sys,'/',['Linear/Inner',13,'Product/in_1']])
set_param([sys,'/',['Linear/Inner',13,'Product/in_1']],...
		'position',[15,25,35,45])

add_block('built-in/Inport',[sys,'/',['Linear/Inner',13,'Product/in_2']])
set_param([sys,'/',['Linear/Inner',13,'Product/in_2']],...
		'Port','2',...
		'position',[15,90,35,110])

add_block('built-in/Outport',[sys,'/',['Linear/Inner',13,'Product/out_1']])
set_param([sys,'/',['Linear/Inner',13,'Product/out_1']],...
		'position',[185,55,205,75])

add_block('built-in/Sum',[sys,'/',['Linear/Inner',13,'Product/Sum']])
set_param([sys,'/',['Linear/Inner',13,'Product/Sum']],...
		'inputs','+',...
		'position',[125,55,145,75])

add_block('built-in/Product',[sys,'/',['Linear/Inner',13,'Product/Product']])
set_param([sys,'/',['Linear/Inner',13,'Product/Product']],...
		'position',[65,55,90,75])
add_line([sys,'/',['Linear/Inner',13,'Product']],[150,65;180,65])
add_line([sys,'/',['Linear/Inner',13,'Product']],[95,65;120,65])
add_line([sys,'/',['Linear/Inner',13,'Product']],[40,35;60,60])
add_line([sys,'/',['Linear/Inner',13,'Product']],[40,100;60,70])
set_param([sys,'/',['Linear/Inner',13,'Product']],...
		'Mask Display','.\n',...
		'Mask Type','Dot Product',...
		'Mask Dialogue','Inner (dot) product.\ny=sum(u1.*u2)')
set_param([sys,'/',['Linear/Inner',13,'Product']],...
		'Mask Help','Computes the inner (dot) product of the inputs: sum(u1.*u2).  The inputs are vectors of the same length. Output is a scalar.')


%     Finished composite block ['Linear/Inner',13,'Product'].

set_param([sys,'/',['Linear/Inner',13,'Product']],...
		'position',[130,39,150,61])

add_block('built-in/Sum',[sys,'/','Linear/Sum'])
set_param([sys,'/','Linear/Sum'],...
		'position',[45,40,65,60])

add_block('built-in/Integrator',[sys,'/','Linear/Integrator'])
set_param([sys,'/','Linear/Integrator'],...
		'position',[45,95,65,115])

add_block('built-in/Derivative',[sys,'/','Linear/Derivative'])
set_param([sys,'/','Linear/Derivative'],...
		'position',[125,95,155,115])

add_block('built-in/Transfer Fcn',[sys,'/','Linear/Transfer Fcn'])
set_param([sys,'/','Linear/Transfer Fcn'],...
		'Denominator','[1 1]',...
		'position',[35,207,70,243])

add_block('built-in/Zero-Pole',[sys,'/','Linear/Zero-Pole'])
set_param([sys,'/','Linear/Zero-Pole'],...
		'Poles','[0; -1]',...
		'position',[115,207,160,243])

add_block('built-in/Gain',[sys,'/','Linear/Gain'])
set_param([sys,'/','Linear/Gain'],...
		'position',[20,147,45,173])

add_block('built-in/State-Space',[sys,'/',['Linear/Matrix',13,'Gain']])
set_param([sys,'/',['Linear/Matrix',13,'Gain']],...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','K',...
		'Mask Type','Matrix Gain',...
		'Mask Dialogue','Matrix Gain.|Gain matrix:',...
		'Mask Translate','K = @1;')
set_param([sys,'/',['Linear/Matrix',13,'Gain']],...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','eye(3,3)\/',...
		'position',[80,146,105,174])

add_block('built-in/Gain',[sys,'/',['Linear/Slider',13,'Gain']])
set_param([sys,'/',['Linear/Slider',13,'Gain']],...
		'Gain','1.317',...
		'Mask Display','1.317',...
		'Mask Dialogue','eval(''slideg(0,1.214,2,0)'');',...
		'position',[130,146,180,174])

add_block('built-in/State-Space',[sys,'/','Linear/State-Space'])
set_param([sys,'/','Linear/State-Space'],...
		'position',[60,269,135,311])


%     Finished composite block 'Linear'.

set_param([sys,'/','Linear'],...
		'position',[210,5,240,55])


%     Subsystem  'Connections'.

new_system([sys,'/','Connections'])
set_param([sys,'/','Connections'],'Location',[340,287,463,522])

add_block('built-in/Mux',[sys,'/','Connections/Mux'])
set_param([sys,'/','Connections/Mux'],...
		'inputs','3',...
		'position',[50,124,80,156])

add_block('built-in/Demux',[sys,'/','Connections/Demux'])
set_param([sys,'/','Connections/Demux'],...
		'outputs','3',...
		'position',[45,174,85,206])

add_block('built-in/Outport',[sys,'/','Connections/Outport'])
set_param([sys,'/','Connections/Outport'],...
		'position',[55,80,75,100])

add_block('built-in/Inport',[sys,'/','Connections/Inport'])
set_param([sys,'/','Connections/Inport'],...
		'position',[55,40,75,60])

add_block('built-in/Note',[sys,'/','Connections/Library'])
set_param([sys,'/','Connections/Library'],...
		'position',[65,15,70,20])

add_block('built-in/Note',[sys,'/','Connections/Connections'])
set_param([sys,'/','Connections/Connections'],...
		'position',[65,0,70,5])


%     Finished composite block 'Connections'.

set_param([sys,'/','Connections'],...
		'position',[345,5,375,55])

add_block('built-in/Note',[sys,'/','SIMULINK Block Library (Version 1.3c)'])
set_param([sys,'/','SIMULINK Block Library (Version 1.3c)'],...
		'position',[230,85,235,90])


%     Subsystem  'Extras'.

new_system([sys,'/','Extras'])
set_param([sys,'/','Extras'],'Location',[0,0,123,235])
set_param([sys,'/','Extras'],...
		'Mask Display','',...
		'Mask Dialogue','eval(''extras'')')


%     Finished composite block 'Extras'.

set_param([sys,'/','Extras'],...
		'position',[415,5,445,55])


%     Subsystem  'Sources'.

new_system([sys,'/','Sources'])
set_param([sys,'/','Sources'],'Location',[18,195,276,532])

add_block('built-in/Note',[sys,'/','Sources/Signal Source Library'])
set_param([sys,'/','Sources/Signal Source Library'],...
		'position',[135,0,140,5])

add_block('built-in/White Noise',[sys,'/',['Sources/Random',13,'Number']])
set_param([sys,'/',['Sources/Random',13,'Number']],...
		'position',[30,257,75,293])


%     Subsystem  'Sources/Chirp Signal'.

new_system([sys,'/','Sources/Chirp Signal'])
set_param([sys,'/','Sources/Chirp Signal'],'Location',[466,243,956,594])

add_block('built-in/Clock',[sys,'/','Sources/Chirp Signal/Clock'])
set_param([sys,'/','Sources/Chirp Signal/Clock'],...
		'position',[50,75,70,95])

add_block('built-in/Fcn',[sys,'/','Sources/Chirp Signal/Fcn'])
set_param([sys,'/','Sources/Chirp Signal/Fcn'],...
		'Expr','sin(AA*u*u + BB*u)',...
		'position',[95,60,160,110])

add_block('built-in/Outport',[sys,'/','Sources/Chirp Signal/out_1'])
set_param([sys,'/','Sources/Chirp Signal/out_1'],...
		'position',[190,75,210,95])
add_line([sys,'/','Sources/Chirp Signal'],[75,85;90,85])
add_line([sys,'/','Sources/Chirp Signal'],[165,85;185,85])
set_param([sys,'/','Sources/Chirp Signal'],...
		'Mask Display','plot(t,sin(t.*t))',...
		'Mask Type','chirp')
set_param([sys,'/','Sources/Chirp Signal'],...
		'Mask Dialogue','Chirp Signal.\n(Sine wave with increasing frequency)|Initial frequency (Hz):| Target time (secs):| Frequency at target time (Hz):')
set_param([sys,'/','Sources/Chirp Signal'],...
		'Mask Translate','BB = 2*pi*@1; AA =pi*(@3 -@1)/(@2);t=[0:.1:5];')
set_param([sys,'/','Sources/Chirp Signal'],...
		'Mask Help','The chirp signal has linearly increasing frequency with time.  This block can be used for spectral analysis of nonlinear systems. ',...
		'Mask Entries','0.1\/100\/1\/')


%     Finished composite block 'Sources/Chirp Signal'.

set_param([sys,'/','Sources/Chirp Signal'],...
		'position',[190,192,230,228])


%     Subsystem  ['Sources/Repeating',13,'Sequence'].

new_system([sys,'/',['Sources/Repeating',13,'Sequence']])
set_param([sys,'/',['Sources/Repeating',13,'Sequence']],'Location',[5,40,315,196])

add_block('built-in/Clock',[sys,'/',['Sources/Repeating',13,'Sequence/Clock']])
set_param([sys,'/',['Sources/Repeating',13,'Sequence/Clock']],...
		'position',[45,60,65,80])

add_block('built-in/Fcn',[sys,'/',['Sources/Repeating',13,'Sequence/Fcn1']])
set_param([sys,'/',['Sources/Repeating',13,'Sequence/Fcn1']],...
		'Expr','rem(u[1],period)',...
		'position',[110,60,150,80])

add_block('built-in/Look Up Table',[sys,'/',['Sources/Repeating',13,'Sequence/Look-Up Table']])
set_param([sys,'/',['Sources/Repeating',13,'Sequence/Look-Up Table']],...
		'Input_Values','t',...
		'Output_Values','y',...
		'position',[210,58,250,82])

add_block('built-in/Outport',[sys,'/',['Sources/Repeating',13,'Sequence/out_1']])
set_param([sys,'/',['Sources/Repeating',13,'Sequence/out_1']],...
		'position',[285,60,305,80])
add_line([sys,'/',['Sources/Repeating',13,'Sequence']],[155,70;205,70])
add_line([sys,'/',['Sources/Repeating',13,'Sequence']],[70,70;105,70])
add_line([sys,'/',['Sources/Repeating',13,'Sequence']],[255,70;280,70])
set_param([sys,'/',['Sources/Repeating',13,'Sequence']],...
		'Mask Display','plot([t,t+period,t+2*period],[y,y,y])',...
		'Mask Type','Repeating table')
set_param([sys,'/',['Sources/Repeating',13,'Sequence']],...
		'Mask Dialogue','Repeating table.\nEnter values of time and output for first cycle.|Time values:|Output values:',...
		'Mask Translate','period = max(@1); t = @1; y = @2;')
set_param([sys,'/',['Sources/Repeating',13,'Sequence']],...
		'Mask Help','Repeats cycle given in table. Time values should be monotonically increasing.',...
		'Mask Entries','[0 2 2]\/[0 2 0]\/')


%     Finished composite block ['Sources/Repeating',13,'Sequence'].

set_param([sys,'/',['Sources/Repeating',13,'Sequence']],...
		'position',[195,37,230,73])


%     Subsystem  ['Sources/Band-Limited',13,'White Noise'].

new_system([sys,'/',['Sources/Band-Limited',13,'White Noise']])
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],'Location',[54,341,339,470])

add_block('built-in/White Noise',[sys,'/',['Sources/Band-Limited',13,'White Noise/White Noise']])
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise/White Noise']],...
		'Seed','seed',...
		'position',[25,40,45,60])

add_block('built-in/Zero-Order Hold',[sys,'/',['Sources/Band-Limited',13,'White Noise/Zero-Order',13,'Hold']])
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise/Zero-Order',13,'Hold']],...
		'Sample time','Ts',...
		'position',[85,34,120,66])

add_block('built-in/Gain',[sys,'/',['Sources/Band-Limited',13,'White Noise/Gain']])
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise/Gain']],...
		'Gain','[sqrt(Cov)]/[sqrt(Ts)]',...
		'position',[155,31,195,69])

add_block('built-in/Outport',[sys,'/',['Sources/Band-Limited',13,'White Noise/Out_1']])
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise/Out_1']],...
		'position',[230,40,250,60])
add_line([sys,'/',['Sources/Band-Limited',13,'White Noise']],[125,50;150,50])
add_line([sys,'/',['Sources/Band-Limited',13,'White Noise']],[200,50;225,50])
add_line([sys,'/',['Sources/Band-Limited',13,'White Noise']],[50,50;80,50])
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],...
		'Mask Display','plot(t(:),r2(:))',...
		'Mask Type','Continuous White Noise.')
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],...
		'Mask Dialogue','White noise for continuous (s-domain) systems.\nBand-limited using zero-order-hold.|Noise Power:|Sample Time:|Seed')
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],...
		'Mask Translate','Cov = @1; Ts = @2; seed = @3; r = rand(1,12); r2 = [r(1),r;r,r(12)]; t =[1:13;1:13];')
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],...
		'Mask Help','Implemented using white noise into Zero-Order Hold block. The seed and power can be vectors of the same length to produce a vector of white noise sources. For faster simulation, set sample time to the highest value possible but in accordance with the fastest dynamics of system.')
set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],...
		'Mask Entries','[0.1]\/0.1\/[23341]\/')


%     Finished composite block ['Sources/Band-Limited',13,'White Noise'].

set_param([sys,'/',['Sources/Band-Limited',13,'White Noise']],...
		'position',[110,257,155,293])

add_block('built-in/Signal Generator',[sys,'/',['Sources/Signal',13,'Generator']])
set_param([sys,'/',['Sources/Signal',13,'Generator']],...
		'Peak','1.000000',...
		'Peak Range','5.000000',...
		'Freq','1.000000',...
		'Freq Range','5.000000',...
		'Wave','Sin',...
		'Units','Rads',...
		'position',[35,83,80,117])

add_block('built-in/Constant',[sys,'/','Sources/Constant'])
set_param([sys,'/','Sources/Constant'],...
		'position',[125,90,145,110])

add_block('built-in/Sine Wave',[sys,'/','Sources/Sine Wave'])
set_param([sys,'/','Sources/Sine Wave'],...
		'position',[40,150,60,170])

add_block('built-in/Step Fcn',[sys,'/','Sources/Step Input'])
set_param([sys,'/','Sources/Step Input'],...
		'position',[125,150,145,170])

add_block('built-in/From File',[sys,'/','Sources/From File'])
set_param([sys,'/','Sources/From File'],...
		'position',[15,196,85,224])

add_block('built-in/From Workspace',[sys,'/',['Sources/From',13,'Workspace']])
set_param([sys,'/',['Sources/From',13,'Workspace']],...
		'position',[115,192,155,218])

add_block('built-in/Digital Clock',[sys,'/','Sources/Digital Clock'])
set_param([sys,'/','Sources/Digital Clock'],...
		'position',[120,35,155,65])

add_block('built-in/Clock',[sys,'/','Sources/Clock'])
set_param([sys,'/','Sources/Clock'],...
		'position',[45,40,65,60])


%     Subsystem  ['Sources/Pulse',13,'Generator'].

new_system([sys,'/',['Sources/Pulse',13,'Generator']])
set_param([sys,'/',['Sources/Pulse',13,'Generator']],'Location',[158,441,759,682])

add_block('built-in/Unit Delay',[sys,'/',['Sources/Pulse',13,'Generator/Unit Delay1']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Unit Delay1']],...
		'orientation',2,...
		'Sample time','[Ts,st2]',...
		'x0','ini',...
		'position',[140,165,190,185])

add_block('built-in/Unit Delay',[sys,'/',['Sources/Pulse',13,'Generator/Unit Delay']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Unit Delay']],...
		'orientation',2,...
		'Sample time','[Ts,st1]',...
		'position',[145,75,195,95])

add_block('built-in/Constant',[sys,'/',['Sources/Pulse',13,'Generator/Constant']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Constant']],...
		'position',[25,30,45,50])

add_block('built-in/Sum',[sys,'/',['Sources/Pulse',13,'Generator/Sum']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Sum']],...
		'hide name',0,...
		'inputs','+-',...
		'position',[135,35,155,55])

add_block('built-in/Sum',[sys,'/',['Sources/Pulse',13,'Generator/Sum1']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Sum1']],...
		'hide name',0,...
		'inputs','+-',...
		'position',[130,120,150,140])

add_block('built-in/Relational Operator',[sys,'/',['Sources/Pulse',13,'Generator/Relational',13,'operator']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Relational',13,'operator']],...
		'hide name',0,...
		'position',[370,102,400,133])

add_block('built-in/Clock',[sys,'/',['Sources/Pulse',13,'Generator/Clock1']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Clock1']],...
		'hide name',0,...
		'position',[295,100,315,120])

add_block('built-in/Constant',[sys,'/',['Sources/Pulse',13,'Generator/Constant1']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Constant1']],...
		'Value','stt',...
		'position',[295,149,320,171])

add_block('built-in/Logical Operator',[sys,'/',['Sources/Pulse',13,'Generator/Logical',13,'Operator']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Logical',13,'Operator']],...
		'Operator','XOR',...
		'position',[285,38,315,62])

add_block('built-in/Logical Operator',[sys,'/',['Sources/Pulse',13,'Generator/Logical',13,'Operator1']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Logical',13,'Operator1']],...
		'Operator','NOT',...
		'Number of Input Ports','1',...
		'position',[355,38,385,62])

add_block('built-in/Product',[sys,'/',['Sources/Pulse',13,'Generator/Product']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Product']],...
		'hide name',0,...
		'position',[455,105,480,125])

add_block('built-in/Gain',[sys,'/',['Sources/Pulse',13,'Generator/Gain']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/Gain']],...
		'hide name',0,...
		'Gain','ht',...
		'position',[510,102,535,128])

add_block('built-in/Outport',[sys,'/',['Sources/Pulse',13,'Generator/out_1']])
set_param([sys,'/',['Sources/Pulse',13,'Generator/out_1']],...
		'hide name',0,...
		'position',[560,105,580,125])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[155,130;245,130;245,55;280,55])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[160,45;280,45])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[50,40;70,40;70,125;125,125])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[135,175;100,175;100,135;125,135])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[155,130;210,130;210,175;195,175])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[50,40;130,40])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[160,45;230,45;230,85;200,85])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[140,85;105,85;105,50;130,50])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[320,110;365,110])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[405,120;450,120])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[485,115;505,115])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[540,115;555,115])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[325,160;345,160;345,125;365,125])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[320,50;350,50])
add_line([sys,'/',['Sources/Pulse',13,'Generator']],[390,50;430,50;430,110;450,110])
set_param([sys,'/',['Sources/Pulse',13,'Generator']],...
		'Mask Display','plot(0,0,100,100,[90,75,75,60,60,35,35,20,20,10],[20,20,80,80,20,20,80,80,20,20])',...
		'Mask Type','Pulse Generator')
set_param([sys,'/',['Sources/Pulse',13,'Generator']],...
		'Mask Dialogue','Pulse Generator.|Pulse period (secs):|Pulse width:|Pulse height:|Pulse start time:')
set_param([sys,'/',['Sources/Pulse',13,'Generator']],...
		'Mask Translate','Ts=@1; du=@2; ht=@3; stt=@4; ini=ones(length(ht),1); st1=rem(stt,Ts); st2=rem(stt+du,Ts);if(Ts<=1.2*du),ini=zeros(length(ht),1);end;')
set_param([sys,'/',['Sources/Pulse',13,'Generator']],...
		'Mask Help','Pulse generator which ensures pulse\ntransitions are hit. Provides a vector of pulses when the height is entered as a vector.\nUnmask to see how it works.')
set_param([sys,'/',['Sources/Pulse',13,'Generator']],...
		'Mask Entries','3\/1\/1\/0.5\/')


%     Finished composite block ['Sources/Pulse',13,'Generator'].

set_param([sys,'/',['Sources/Pulse',13,'Generator']],...
		'position',[195,112,230,148])


%     Finished composite block 'Sources'.

set_param([sys,'/','Sources'],...
		'position',[15,6,45,56])


%     Subsystem  'Discrete'.

new_system([sys,'/','Discrete'])
set_param([sys,'/','Discrete'],'Location',[111,234,320,613])

add_block('built-in/Zero-Order Hold',[sys,'/',['Discrete/Zero-Order',13,'Hold']])
set_param([sys,'/',['Discrete/Zero-Order',13,'Hold']],...
		'position',[45,244,80,276])

add_block('built-in/Discrete Zero-Pole',[sys,'/',['Discrete/Discrete',13,'Zero-Pole']])
set_param([sys,'/',['Discrete/Discrete',13,'Zero-Pole']],...
		'Poles','[0; 0.5]',...
		'position',[125,33,185,67])

add_block('built-in/Unit Delay',[sys,'/','Discrete/Unit Delay'])
set_param([sys,'/','Discrete/Unit Delay'],...
		'position',[40,42,90,58])

add_block('built-in/Filter',[sys,'/','Discrete/Filter'])
set_param([sys,'/','Discrete/Filter'],...
		'Denominator','[1 2]',...
		'position',[35,101,95,139])

add_block('built-in/Discrete Transfer Fcn',[sys,'/',['Discrete/Discrete',13,'Transfer Fcn']])
set_param([sys,'/',['Discrete/Discrete',13,'Transfer Fcn']],...
		'Denominator','[1 0.5]',...
		'position',[135,102,180,138])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete/Discrete State-Space'])
set_param([sys,'/','Discrete/Discrete State-Space'],...
		'position',[45,173,160,217])

add_block('built-in/Note',[sys,'/','Discrete/Discrete-Time Library'])
set_param([sys,'/','Discrete/Discrete-Time Library'],...
		'position',[105,5,110,10])


%     Subsystem  ['Discrete/Discrete-Time',13,'Integrator'].

new_system([sys,'/',['Discrete/Discrete-Time',13,'Integrator']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],'Location',[392,641,765,859])

add_block('built-in/Outport',[sys,'/',['Discrete/Discrete-Time',13,'Integrator/out_1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator/out_1']],...
		'position',[320,85,340,105])

add_block('built-in/Gain',[sys,'/',['Discrete/Discrete-Time',13,'Integrator/Gain']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator/Gain']],...
		'Gain','Ts',...
		'position',[80,61,110,99])

add_block('built-in/Unit Delay',[sys,'/',['Discrete/Discrete-Time',13,'Integrator/Unit Delay']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator/Unit Delay']],...
		'Sample time','Ts',...
		'x0','X0',...
		'position',[210,85,260,105])

add_block('built-in/Sum',[sys,'/',['Discrete/Discrete-Time',13,'Integrator/Sum']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator/Sum']],...
		'position',[150,63,180,127])

add_block('built-in/Inport',[sys,'/',['Discrete/Discrete-Time',13,'Integrator/in_1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator/in_1']],...
		'position',[25,70,45,90])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],[265,95;315,95])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],[285,95;285,165;120,165;120,110;145,110])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],[185,95;205,95])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],[50,80;75,80])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],[115,80;145,80])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],...
		'Mask Display','dpoly(Ts,[1 -1],''z'')',...
		'Mask Type','Discrete-Time Integrator',...
		'Mask Dialogue','Discrete-Time Integrator:|Initial Condition:|Sample Time:')
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],...
		'Mask Translate','X0=@1;Ts=@2;',...
		'Mask Help','Implements a zeroth order discrete\nintegration using a gain, a sum, and\na unit delay. Inputs may be scalar\nor vector.\n')
set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],...
		'Mask Entries','0\/1\/')


%     Finished composite block ['Discrete/Discrete-Time',13,'Integrator'].

set_param([sys,'/',['Discrete/Discrete-Time',13,'Integrator']],...
		'position',[40,309,80,351])


%     Subsystem  ['Discrete/First-Order',13,'Hold'].

new_system([sys,'/',['Discrete/First-Order',13,'Hold']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold']],'Location',[511,151,915,322])

add_block('built-in/Zero-Order Hold',[sys,'/',['Discrete/First-Order',13,'Hold/Zero-Order',13,'Hold']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/Zero-Order',13,'Hold']],...
		'Sample time','Ts',...
		'position',[100,29,135,61])

add_block('built-in/Gain',[sys,'/',['Discrete/First-Order',13,'Hold/Gain']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/Gain']],...
		'Gain','1/Ts',...
		'position',[285,33,325,77])

add_block('built-in/Integrator',[sys,'/',['Discrete/First-Order',13,'Hold/Integrator']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/Integrator']],...
		'position',[235,42,260,68])

add_block('built-in/Sum',[sys,'/',['Discrete/First-Order',13,'Hold/Sum']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/Sum']],...
		'inputs','+-',...
		'position',[190,37,210,68])

add_block('built-in/Unit Delay',[sys,'/',['Discrete/First-Order',13,'Hold/Unit Delay']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/Unit Delay']],...
		'Sample time','Ts',...
		'position',[90,93,140,117])

add_block('built-in/Inport',[sys,'/',['Discrete/First-Order',13,'Hold/input']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/input']],...
		'position',[25,35,45,55])

add_block('built-in/Outport',[sys,'/',['Discrete/First-Order',13,'Hold/output']])
set_param([sys,'/',['Discrete/First-Order',13,'Hold/output']],...
		'position',[345,45,365,65])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[330,55;340,55])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[265,55;280,55])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[215,55;230,55])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[145,105;165,105;165,60;185,60])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[140,45;185,45])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[50,45;95,45])
add_line([sys,'/',['Discrete/First-Order',13,'Hold']],[65,45;65,105;85,105])
set_param([sys,'/',['Discrete/First-Order',13,'Hold']],...
		'Mask Display','plot(0,0,100,100,[90,70,50,30,10],[60,40,80,30,20])',...
		'Mask Type','First-Order Hold',...
		'Mask Dialogue','First-Order Hold|Sample Time:')
set_param([sys,'/',['Discrete/First-Order',13,'Hold']],...
		'Mask Translate','Ts=@1;',...
		'Mask Help','Implements a First-Order sample-and-hold latch operating at the sampling interval you specify.',...
		'Mask Entries','1\/')


%     Finished composite block ['Discrete/First-Order',13,'Hold'].

set_param([sys,'/',['Discrete/First-Order',13,'Hold']],...
		'position',[140,244,175,276])


%     Subsystem  ['Discrete/Discrete-Time',13,'Limited Integrator'].

new_system([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],'Location',[137,84,904,403])

add_block('built-in/Outport',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/out_1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/out_1']],...
		'position',[685,150,705,170])

add_block('built-in/Inport',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/in_1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/in_1']],...
		'position',[60,115,80,135])

add_block('built-in/Constant',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Constant']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Constant']],...
		'hide name',0,...
		'Value','upper_limit',...
		'position',[140,174,210,196])

add_block('built-in/Switch',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Switch']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Switch']],...
		'hide name',0,...
		'Threshold','0.5',...
		'position',[315,99,340,201])

add_block('built-in/Sum',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Sum']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Sum']],...
		'hide name',0,...
		'position',[170,95,195,135])

add_block('built-in/Gain',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Gain']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Gain']],...
		'Gain','Ts',...
		'position',[110,106,140,144])

add_block('built-in/Relational Operator',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Relational',13,'operator']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Relational',13,'operator']],...
		'hide name',0,...
		'Operator','<',...
		'position',[245,131,270,164])

add_block('built-in/Relational Operator',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Relational',13,'operator1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Relational',13,'operator1']],...
		'hide name',0,...
		'Operator','>',...
		'position',[450,142,480,173])

add_block('built-in/Constant',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Constant1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Constant1']],...
		'hide name',0,...
		'Value','lower_limit',...
		'position',[140,218,210,242])

add_block('built-in/Switch',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Switch1']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Switch1']],...
		'hide name',0,...
		'Threshold','0.5',...
		'position',[520,110,555,210])

add_block('built-in/Unit Delay',[sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Unit Delay']])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator/Unit Delay']],...
		'Sample time','Ts',...
		'x0','X0',...
		'position',[605,150,655,170])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[660,160;680,160])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[85,125;105,125])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[200,115;310,115])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[275,150;310,150])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[220,115;220,140;240,140])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[145,125;165,125])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[215,185;220,185;220,155;240,155])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[215,185;310,185])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[345,150;445,150])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[380,150;380,125;515,125])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[215,230;430,230;430,165;445,165])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[485,160;515,160])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[430,195;515,195])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[560,160;600,160])
add_line([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],[670,160;670,70;150,70;150,105;165,105])
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],...
		'Mask Display','plot(-1,-0.2,3.5,1.2,[0,1,2,2.9],[0,0,1,1],[0,1],[0.5,0.5], [.5,.5], [.8,.6], [.05,.35,.05,.35],[.4,.4,.2,.2], [.45,.65],[.3,.3], [.9,.9],[.2,.4]);')
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],...
		'Mask Type','Discrete-Time Limited Integrator.',...
		'Mask Dialogue','Discrete-Time Limited Integrator.|Lower bound:|Upper bound:|Initial condition:|Sampling Time:')
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],...
		'Mask Translate','lower_limit=@1;upper_limit=@2;X0=@3;Ts=@4;',...
		'Mask Help','Discrete-Time Limited Integrator. Unmask to see details.')
set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],...
		'Mask Entries','-1\/1\/0\/1\/')


%     Finished composite block ['Discrete/Discrete-Time',13,'Limited Integrator'].

set_param([sys,'/',['Discrete/Discrete-Time',13,'Limited Integrator']],...
		'position',[135,307,180,353])


%     Finished composite block 'Discrete'.

set_param([sys,'/','Discrete'],...
		'position',[145,5,175,55])


%     Subsystem  'Nonlinear'.

new_system([sys,'/','Nonlinear'])
set_param([sys,'/','Nonlinear'],'Location',[164,212,491,613])

add_block('built-in/Note',[sys,'/','Nonlinear/Nonlinear Library'])
set_param([sys,'/','Nonlinear/Nonlinear Library'],...
		'position',[160,1,165,6])

add_block('built-in/Rate Limiter',[sys,'/','Nonlinear/Rate Limiter'])
set_param([sys,'/','Nonlinear/Rate Limiter'],...
		'position',[260,82,290,108])

add_block('built-in/Saturation',[sys,'/','Nonlinear/Saturation'])
set_param([sys,'/','Nonlinear/Saturation'],...
		'position',[260,33,290,57])

add_block('built-in/Dead Zone',[sys,'/','Nonlinear/Dead Zone'])
set_param([sys,'/','Nonlinear/Dead Zone'],...
		'position',[110,82,140,108])

add_block('built-in/Backlash',[sys,'/','Nonlinear/Backlash'])
set_param([sys,'/','Nonlinear/Backlash'],...
		'position',[185,33,215,57])

add_block('built-in/Look Up Table',[sys,'/',['Nonlinear/Coulombic',13,'Friction']])
set_param([sys,'/',['Nonlinear/Coulombic',13,'Friction']],...
		'Input_Values','[-1,0,0,1]',...
		'Output_Values','[-gain-ini -ini ini gain+ini]',...
		'Mask Display','plot([-1 0 0 1],[-gain-ini, -ini, ini, gain+ini],[-1 1],[0 0],[0 0],[-x,x])')
set_param([sys,'/',['Nonlinear/Coulombic',13,'Friction']],...
		'Mask Type','Coulombic Friction',...
		'Mask Dialogue','Coulombic Friction\ny = sign(x) * (Gain * abs(x) + Offset)|Offset discontinuity at zero:|Gain:')
set_param([sys,'/',['Nonlinear/Coulombic',13,'Friction']],...
		'Mask Translate','ini=@1;gain=@2;x=max(ini,gain+ini);',...
		'Mask Help','This block has a discontinuity\nat zero and a linear gain afterward.\ny= sign(x)*(Gain*abs(x)+Offset)')
set_param([sys,'/',['Nonlinear/Coulombic',13,'Friction']],...
		'Mask Entries','1\/1\/',...
		'position',[185,82,215,108])

add_block('built-in/S-Function',[sys,'/','Nonlinear/Quantizer'])
set_param([sys,'/','Nonlinear/Quantizer'],...
		'function name','quantize',...
		'parameters','q',...
		'Mask Display','plot([-4,4],[0,0],[0,0],[-4,4],[-3,-2,-2,-1,-1,0,0,1,1,2,2,3,3,4]-0.5,[-3,-3,-2,-2,-1,-1,0,0,1,1,2,2,3,3])')
set_param([sys,'/','Nonlinear/Quantizer'],...
		'Mask Type','Quantizer',...
		'Mask Dialogue','Discretizes input at given interval.|Quantization interval:',...
		'Mask Translate','q = @1;',...
		'Mask Help','Quantizes input in given intervals. ')
set_param([sys,'/','Nonlinear/Quantizer'],...
		'Mask Entries','0.5\/',...
		'position',[30,82,60,108])

add_block('built-in/Relay',[sys,'/','Nonlinear/Relay'])
set_param([sys,'/','Nonlinear/Relay'],...
		'position',[110,33,140,57])


%     Subsystem  'Nonlinear/Sign'.

new_system([sys,'/','Nonlinear/Sign'])
set_param([sys,'/','Nonlinear/Sign'],'Location',[159,417,467,586])

add_block('built-in/Constant',[sys,'/','Nonlinear/Sign/Constant'])
set_param([sys,'/','Nonlinear/Sign/Constant'],...
		'Value','0',...
		'position',[65,105,85,125])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Sign/Relational',13,'Operator1']])
set_param([sys,'/',['Nonlinear/Sign/Relational',13,'Operator1']],...
		'Operator','<',...
		'position',[140,92,170,123])

add_block('built-in/Sum',[sys,'/','Nonlinear/Sign/Sum'])
set_param([sys,'/','Nonlinear/Sign/Sum'],...
		'inputs','+-',...
		'position',[215,64,235,91])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Sign/Relational',13,'Operator']])
set_param([sys,'/',['Nonlinear/Sign/Relational',13,'Operator']],...
		'Operator','>',...
		'position',[140,32,170,63])

add_block('built-in/Inport',[sys,'/','Nonlinear/Sign/in_1'])
set_param([sys,'/','Nonlinear/Sign/in_1'],...
		'position',[35,30,55,50])

add_block('built-in/Outport',[sys,'/','Nonlinear/Sign/out_1'])
set_param([sys,'/','Nonlinear/Sign/out_1'],...
		'position',[265,70,285,90])
add_line([sys,'/','Nonlinear/Sign'],[240,80;260,80])
add_line([sys,'/','Nonlinear/Sign'],[175,50;185,50;185,70;210,70])
add_line([sys,'/','Nonlinear/Sign'],[175,110;185,110;185,85;210,85])
add_line([sys,'/','Nonlinear/Sign'],[90,115;135,115])
add_line([sys,'/','Nonlinear/Sign'],[110,115;110,55;135,55])
add_line([sys,'/','Nonlinear/Sign'],[60,40;135,40])
add_line([sys,'/','Nonlinear/Sign'],[95,40;95,100;135,100])
set_param([sys,'/','Nonlinear/Sign'],...
		'Mask Display','plot(-50,-50,50,50,[-50,50],[0,0],[0,0],[-50,50],[-40,0],[-30,-30],[0,40],[30,30])',...
		'Mask Type','Sign',...
		'Mask Dialogue','y = sign(x)')
set_param([sys,'/','Nonlinear/Sign'],...
		'Mask Help','Sign Function:\n\t\t\ty = 1 if x > 0\n\t\t\ty = 0 if x = 0\n\t\t\ty = -1 if x < 0')


%     Finished composite block 'Nonlinear/Sign'.

set_param([sys,'/','Nonlinear/Sign'],...
		'position',[30,32,60,58])


%     Subsystem  ['Nonlinear/2-D Look-Up',13,'Table'].

new_system([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],'Location',[316,263,598,417])

add_block('built-in/Mux',[sys,'/',['Nonlinear/2-D Look-Up',13,'Table/Mux']])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table/Mux']],...
		'inputs','2',...
		'position',[90,46,120,79])

add_block('built-in/S-Function',[sys,'/',['Nonlinear/2-D Look-Up',13,'Table/S-function']])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table/S-function']],...
		'function name','sftable2',...
		'parameters','xindex, yindex, table',...
		'position',[140,52,190,78])

add_block('built-in/Inport',[sys,'/',['Nonlinear/2-D Look-Up',13,'Table/x0']])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table/x0']],...
		'position',[20,25,40,45])

add_block('built-in/Outport',[sys,'/',['Nonlinear/2-D Look-Up',13,'Table/table out']])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table/table out']],...
		'position',[215,55,235,75])

add_block('built-in/Inport',[sys,'/',['Nonlinear/2-D Look-Up',13,'Table/y0']])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table/y0']],...
		'Port','2',...
		'position',[20,80,40,100])
add_line([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],[125,65;135,65])
add_line([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],[45,35;65,35;65,55;85,55])
add_line([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],[195,65;210,65])
add_line([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],[45,90;65,90;65,70;85,70])
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],...
		'Mask Display','plot(-10,-10,110,110,[90,50,10],[90,40,30],[90,50,10],[50,26,20],[90,50,10],[22,13,10])',...
		'Mask Type','2-D Table Lookup')
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],...
		'Mask Dialogue','Two Dimensional Table Lookup\nThe first input corresponds to X Index and the second input corresponds to the Y Index|X Index|Y Index|Table')
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],...
		'Mask Translate','xindex=@1; yindex=@2; table=@3; sftab2chk(xindex,yindex,table);')
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],...
		'Mask Help','This block returns a linearly interpolated intersection from the table using the X index (which corresponds to the rows of the table) and the Y index (which corresponds to the columns of the table).  Extrapolation is used.')
set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],...
		'Mask Entries','sort(rand(10,1))*2-1\/sort(rand(10,1))*2-1\/magic(10)-50\/')


%     Finished composite block ['Nonlinear/2-D Look-Up',13,'Table'].

set_param([sys,'/',['Nonlinear/2-D Look-Up',13,'Table']],...
		'position',[260,138,290,162])

add_block('built-in/Look Up Table',[sys,'/',['Nonlinear/Look-Up',13,'Table']])
set_param([sys,'/',['Nonlinear/Look-Up',13,'Table']],...
		'position',[185,138,215,162])

add_block('built-in/Abs',[sys,'/','Nonlinear/Abs'])
set_param([sys,'/','Nonlinear/Abs'],...
		'position',[110,138,140,162])

add_block('built-in/Product',[sys,'/','Nonlinear/Product'])
set_param([sys,'/','Nonlinear/Product'],...
		'position',[30,138,60,162])

add_block('built-in/Switch',[sys,'/','Nonlinear/Switch'])
set_param([sys,'/','Nonlinear/Switch'],...
		'position',[260,199,290,231])

add_block('built-in/Combinatorial Logic',[sys,'/',['Nonlinear/Combinatorial',13,'Logic']])
set_param([sys,'/',['Nonlinear/Combinatorial',13,'Logic']],...
		'position',[185,198,215,222])

add_block('built-in/Logical Operator',[sys,'/',['Nonlinear/Logical',13,'Operator']])
set_param([sys,'/',['Nonlinear/Logical',13,'Operator']],...
		'Operator','AND',...
		'position',[110,198,140,222])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Relational',13,'Operator']])
set_param([sys,'/',['Nonlinear/Relational',13,'Operator']],...
		'position',[30,198,60,222])

add_block('built-in/S-Function',[sys,'/','Nonlinear/S-Function'])
set_param([sys,'/','Nonlinear/S-Function'],...
		'position',[100,265,150,285])

add_block('built-in/MATLAB Fcn',[sys,'/','Nonlinear/MATLAB Fcn'])
set_param([sys,'/','Nonlinear/MATLAB Fcn'],...
		'position',[170,258,230,292])

add_block('built-in/Reset Integrator',[sys,'/',['Nonlinear/Reset',13,'Integrator']])
set_param([sys,'/',['Nonlinear/Reset',13,'Integrator']],...
		'Initial','15',...
		'position',[260,260,290,290])

add_block('built-in/Fcn',[sys,'/','Nonlinear/Fcn'])
set_param([sys,'/','Nonlinear/Fcn'],...
		'position',[25,265,65,285])

add_block('built-in/Variable Transport Delay',[sys,'/',['Nonlinear/Variable',13,'Transport Delay']])
set_param([sys,'/',['Nonlinear/Variable',13,'Transport Delay']],...
		'Maximum delay:','10',...
		'position',[180,327,220,358])

add_block('built-in/Transport Delay',[sys,'/',['Nonlinear/Transport',13,'Delay']])
set_param([sys,'/',['Nonlinear/Transport',13,'Delay']],...
		'Delay Time','1',...
		'position',[105,325,145,355])

add_block('built-in/Memory',[sys,'/','Nonlinear/Memory'])
set_param([sys,'/','Nonlinear/Memory'],...
		'position',[25,325,65,355])


%     Subsystem  ['Nonlinear/Limited',13,'Integrator'].

new_system([sys,'/',['Nonlinear/Limited',13,'Integrator']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator']],'Location',[452,229,1117,789])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator']],...
		'hide name',0,...
		'Operator','<=',...
		'position',[415,151,445,204])

add_block('built-in/Constant',[sys,'/',['Nonlinear/Limited',13,'Integrator/Constant']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Constant']],...
		'hide name',0,...
		'Value','upper_limit',...
		'position',[325,179,395,201])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator1']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator1']],...
		'hide name',0,...
		'position',[415,312,445,368])

add_block('built-in/Constant',[sys,'/',['Nonlinear/Limited',13,'Integrator/Constant1']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Constant1']],...
		'hide name',0,...
		'Value','lower_limit',...
		'position',[325,345,390,365])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator3']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator3']],...
		'hide name',0,...
		'position',[415,396,445,449])

add_block('built-in/Relational Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator2']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Relational',13,'operator2']],...
		'hide name',0,...
		'Operator','<=',...
		'position',[415,231,445,284])

add_block('built-in/Logical Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Logical',13,'Operator1']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Logical',13,'Operator1']],...
		'hide name',0,...
		'Operator','OR',...
		'position',[490,200,525,235])

add_block('built-in/Logical Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Logical',13,'Operator2']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Logical',13,'Operator2']],...
		'hide name',0,...
		'Operator','OR',...
		'position',[490,360,525,395])

add_block('built-in/Logical Operator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Logical',13,'Operator']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Logical',13,'Operator']],...
		'hide name',0,...
		'Operator','AND',...
		'position',[570,280,605,315])

add_block('built-in/Constant',[sys,'/',['Nonlinear/Limited',13,'Integrator/Constant3']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Constant3']],...
		'hide name',0,...
		'Value','0',...
		'position',[355,260,375,280])

add_block('built-in/Constant',[sys,'/',['Nonlinear/Limited',13,'Integrator/Constant4']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Constant4']],...
		'hide name',0,...
		'Value','0',...
		'position',[355,425,375,445])

add_block('built-in/Outport',[sys,'/',['Nonlinear/Limited',13,'Integrator/Outport']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Outport']],...
		'position',[515,110,535,130])

add_block('built-in/Inport',[sys,'/',['Nonlinear/Limited',13,'Integrator/Inport']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Inport']],...
		'position',[25,85,45,105])

add_block('built-in/Constant',[sys,'/',['Nonlinear/Limited',13,'Integrator/Constant2']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Constant2']],...
		'Value','0',...
		'position',[20,135,40,155])

add_block('built-in/Integrator',[sys,'/',['Nonlinear/Limited',13,'Integrator/Integrator']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Integrator']],...
		'Initial','X0',...
		'position',[165,99,200,141])

add_block('built-in/Switch',[sys,'/',['Nonlinear/Limited',13,'Integrator/Switch']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Switch']],...
		'Threshold','0.5',...
		'position',[110,80,135,160])

add_block('built-in/Saturation',[sys,'/',['Nonlinear/Limited',13,'Integrator/Saturation']])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator/Saturation']],...
		'Lower Limit','lower_limit',...
		'Upper Limit','upper_limit',...
		'position',[325,110,350,130])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[205,120;245,120;245,165;315,165;315,325;410,325])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[315,165;410,165])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[380,435;410,435])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[380,270;410,270])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[530,380;540,380;540,305;565,305])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[450,425;460,425;460,385;485,385])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[450,340;460,340;460,370;485,370])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[530,220;540,220;540,290;565,290])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[450,260;465,260;465,225;485,225])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[450,180;465,180;465,210;485,210])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[45,145;105,145])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[610,300;625,300;625,490;85,490;85,120;105,120])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[395,355;410,355])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[400,190;410,190])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[140,120;160,120])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[50,95;105,95])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[65,95;65,245;410,245])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[65,245;65,410;410,410])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[205,120;320,120])
add_line([sys,'/',['Nonlinear/Limited',13,'Integrator']],[355,120;510,120])
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator']],...
		'Mask Display','plot(-1,-0.2,3.5,1.2,[0.05,1,2,2.9],[0,0,1,1]); 1/s    ',...
		'Mask Type','Limited Integrator.')
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator']],...
		'Mask Dialogue','Limited Integrator|Lower bound:|Upper bound:|Initial condition:',...
		'Mask Translate','lower_limit=@1;upper_limit=@2;X0=@3;')
set_param([sys,'/',['Nonlinear/Limited',13,'Integrator']],...
		'Mask Help','Implements a limited integrator with \nan expression of the form:\n\nif(x<=lb and u<0) or (x>=ub and u>0)\n   xdot=0\nelse\n   xdot=u',...
		'Mask Entries','-.5\/.5\/0\/')


%     Finished composite block ['Nonlinear/Limited',13,'Integrator'].

set_param([sys,'/',['Nonlinear/Limited',13,'Integrator']],...
		'position',[255,325,295,355])


%     Finished composite block 'Nonlinear'.

set_param([sys,'/','Nonlinear'],...
		'position',[275,5,304,55])


%     Subsystem  'Sinks'.

new_system([sys,'/','Sinks'])
set_param([sys,'/','Sinks'],'Location',[57,236,239,545])

add_block('built-in/Note',[sys,'/','Sinks/Signal Sinks Library'])
set_param([sys,'/','Sinks/Signal Sinks Library'],...
		'position',[95,5,100,10])

add_block('built-in/Stop Simulation',[sys,'/','Sinks/Stop Simulation'])
set_param([sys,'/','Sinks/Stop Simulation'],...
		'position',[105,158,145,192])


%     Subsystem  'Sinks/XY Graph'.

new_system([sys,'/','Sinks/XY Graph'])
set_param([sys,'/','Sinks/XY Graph'],'Location',[8,52,282,245])

add_block('built-in/S-Function',[sys,'/',['Sinks/XY Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Sinks/XY Graph/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunxy',...
		'parameters','ax, st',...
		'position',[185,70,235,90])

add_block('built-in/Mux',[sys,'/','Sinks/XY Graph/Mux'])
set_param([sys,'/','Sinks/XY Graph/Mux'],...
		'inputs','2',...
		'position',[100,61,130,94])

add_block('built-in/Inport',[sys,'/','Sinks/XY Graph/x'])
set_param([sys,'/','Sinks/XY Graph/x'],...
		'position',[10,30,30,50])

add_block('built-in/Inport',[sys,'/','Sinks/XY Graph/y'])
set_param([sys,'/','Sinks/XY Graph/y'],...
		'Port','2',...
		'position',[10,100,30,120])
add_line([sys,'/','Sinks/XY Graph'],[135,80;180,80])
add_line([sys,'/','Sinks/XY Graph'],[35,40;70,40;70,70;95,70])
add_line([sys,'/','Sinks/XY Graph'],[35,110;70,110;70,85;95,85])
set_param([sys,'/','Sinks/XY Graph'],...
		'Mask Display','plot(0,0,100,100,[12,91,91,12,12],[90,90,45,45,90],[51,57,65,75,80,79,75,67,60,54,51,48,42,34,28,27,31,42,51],[71,68,66,66,72,79,83,84,81,77,71,60,54,54,58,65,71,74,71])')
set_param([sys,'/','Sinks/XY Graph'],...
		'Mask Type','XY scope.',...
		'Mask Dialogue','XY scope using MATLAB graph window.\nFirst input is used as time base.\nEnter plotting ranges.|x-min:|x-max:|y-min:|y-max:')
set_param([sys,'/','Sinks/XY Graph'],...
		'Mask Translate','ax = [@1, @2, @3, @4];st=-1;',...
		'Mask Help','This block can be used to explore limit cycles. Look at the m-file sfunxy.m to see how it works.')
set_param([sys,'/','Sinks/XY Graph'],...
		'Mask Entries','-10\/10\/-10\/10\/')


%     Finished composite block 'Sinks/XY Graph'.

set_param([sys,'/','Sinks/XY Graph'],...
		'position',[30,236,60,274])


%     Subsystem  'Sinks/Graph'.

new_system([sys,'/','Sinks/Graph'])
set_param([sys,'/','Sinks/Graph'],'Location',[0,59,274,252])

add_block('built-in/S-Function',[sys,'/',['Sinks/Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Sinks/Graph/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfuny',...
		'parameters','ax, color,dt',...
		'position',[130,55,180,75])

add_block('built-in/Inport',[sys,'/','Sinks/Graph/x'])
set_param([sys,'/','Sinks/Graph/x'],...
		'position',[65,55,85,75])
add_line([sys,'/','Sinks/Graph'],[90,65;125,65])
set_param([sys,'/','Sinks/Graph'],...
		'Mask Display','plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,48,46,56,75,81,84])',...
		'Mask Type','Graph scope.')
set_param([sys,'/','Sinks/Graph'],...
		'Mask Dialogue','Graph scope using MATLAB graph window.\nEnter plotting ranges and line type.|Time range:|y-min:|y-max:|Line type (rgbw-:*). Seperate each plot by ''/'':')
set_param([sys,'/','Sinks/Graph'],...
		'Mask Translate','color = @4; ax = [0, @1, @2, @3]; dt = -1;')
set_param([sys,'/','Sinks/Graph'],...
		'Mask Help','This block plots to the MATLAB graph window and can be used as an improved version of the Scope block. Look at the m-file sfuny.m to see how it works. This block can take scalar or vector input signal.')
set_param([sys,'/','Sinks/Graph'],...
		'Mask Entries','20\/-1.1\/1.2\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Sinks/Graph'.

set_param([sys,'/','Sinks/Graph'],...
		'position',[30,91,60,129])

add_block('built-in/To Workspace',[sys,'/','Sinks/To Workspace'])
set_param([sys,'/','Sinks/To Workspace'],...
		'mat-name','yout',...
		'position',[100,37,150,53])

add_block('built-in/To File',[sys,'/','Sinks/To File'])
set_param([sys,'/','Sinks/To File'],...
		'position',[90,90,165,120])

add_block('built-in/Scope',[sys,'/','Sinks/Scope'])
set_param([sys,'/','Sinks/Scope'],...
		'Vgain','1.000000',...
		'Hgain','1.000000',...
		'Vmax','2.000000',...
		'Hmax','2.000000',...
		'Window',[112,160,443,474],...
		'position',[30,35,60,65])


%     Subsystem  ['Sinks/Auto-Scale',13,'Graph'].

new_system([sys,'/',['Sinks/Auto-Scale',13,'Graph']])
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],'Location',[0,59,274,252])

add_block('built-in/S-Function',[sys,'/',['Sinks/Auto-Scale',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts, dt',...
		'position',[130,55,180,75])

add_block('built-in/Inport',[sys,'/',['Sinks/Auto-Scale',13,'Graph/x']])
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph/x']],...
		'position',[65,55,85,75])
add_line([sys,'/',['Sinks/Auto-Scale',13,'Graph']],[90,65;125,65])
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],...
		'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
		'Mask Type','Storage scope.')
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],...
		'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):')
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],...
		'Mask Help','This block uses a MATLAB figure window to plot the input signal.  The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer.  Line type must be in quotes.  See the M-file sfunyst.m.')
set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],...
		'Mask Entries','5\/-10\/10\/200\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block ['Sinks/Auto-Scale',13,'Graph'].

set_param([sys,'/',['Sinks/Auto-Scale',13,'Graph']],...
		'position',[30,155,60,195])


%     Subsystem  'Sinks/Hit Crossing'.

new_system([sys,'/','Sinks/Hit Crossing'])
set_param([sys,'/','Sinks/Hit Crossing'],'Location',[90,259,548,551])

add_block('built-in/Note',[sys,'/',['Sinks/Hit Crossing/Places discontinuity into integrator',13,'which slows the simulation down. ']])
set_param([sys,'/',['Sinks/Hit Crossing/Places discontinuity into integrator',13,'which slows the simulation down. ']],...
		'position',[145,180,150,185])

add_block('built-in/Reset Integrator',[sys,'/',['Sinks/Hit Crossing/Resetable',13,'Integrator',13,'to stop integral ',13,'wind-up']])
set_param([sys,'/',['Sinks/Hit Crossing/Resetable',13,'Integrator',13,'to stop integral ',13,'wind-up']],...
		'position',[350,37,380,153])

add_block('built-in/Relational Operator',[sys,'/',['Sinks/Hit Crossing/Relational',13,'Operator']])
set_param([sys,'/',['Sinks/Hit Crossing/Relational',13,'Operator']],...
		'Operator','<',...
		'position',[190,37,220,68])

add_block('built-in/Gain',[sys,'/','Sinks/Hit Crossing/Gain'])
set_param([sys,'/','Sinks/Hit Crossing/Gain'],...
		'Gain','1/tol',...
		'position',[265,45,285,65])

add_block('built-in/Inport',[sys,'/','Sinks/Hit Crossing/in_1'])
set_param([sys,'/','Sinks/Hit Crossing/in_1'],...
		'position',[50,35,70,55])

add_block('built-in/Constant',[sys,'/','Sinks/Hit Crossing/Constant1'])
set_param([sys,'/','Sinks/Hit Crossing/Constant1'],...
		'Value','cross',...
		'position',[35,80,85,100])

add_block('built-in/Constant',[sys,'/','Sinks/Hit Crossing/Constant'])
set_param([sys,'/','Sinks/Hit Crossing/Constant'],...
		'Value','0',...
		'position',[235,125,285,145])
add_line([sys,'/','Sinks/Hit Crossing'],[385,95;415,95;415,230;305,230;305,95;345,95])
add_line([sys,'/','Sinks/Hit Crossing'],[290,135;345,135])
add_line([sys,'/','Sinks/Hit Crossing'],[75,45;185,45])
add_line([sys,'/','Sinks/Hit Crossing'],[290,55;345,55])
add_line([sys,'/','Sinks/Hit Crossing'],[90,90;145,90;145,60;185,60])
add_line([sys,'/','Sinks/Hit Crossing'],[225,55;260,55])
set_param([sys,'/','Sinks/Hit Crossing'],...
		'Mask Display','plot(-0.2,-0.2,3.45,1.2,dvec,abs(cos(dvec)),[.6 2.5],[0 0])',...
		'Mask Type','Crossing')
set_param([sys,'/','Sinks/Hit Crossing'],...
		'Mask Dialogue','Causes simulation to take smaller steps at the crossing value (for instance, near a discontinuity). |Crossing Value:|Tol: (typically square simulation tol)')
set_param([sys,'/','Sinks/Hit Crossing'],...
		'Mask Translate','cross=@1; tol=@2;dvec=-.3:.03:(pi+.3);')
set_param([sys,'/','Sinks/Hit Crossing'],...
		'Mask Help','This block causes the simulator to take smaller steps near a crossing point. Systems with discontinuities can be more accurately modeled with this block. Use in conjunction with derivative blocks to stop at rising or falling crossing points.')
set_param([sys,'/','Sinks/Hit Crossing'],...
		'Mask Entries','0\/1e-6\/')


%     Finished composite block 'Sinks/Hit Crossing'.

set_param([sys,'/','Sinks/Hit Crossing'],...
		'position',[105,235,145,275])


%     Finished composite block 'Sinks'.

set_param([sys,'/','Sinks'],...
		'position',[79,5,109,55])

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
