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


%     Subsystem  ['p1(yel)',13,'p2(green)',13,'p3(red)'].

new_system([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']])
set_param([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],'Location',[0,59,274,252])

add_block('built-in/Inport',[sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)/x']])
set_param([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)/x']],...
		'position',[65,55,85,75])

add_block('built-in/S-Function',[sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts, dt',...
		'position',[130,55,180,75])
add_line([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],[90,65;125,65])
set_param([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],...
		'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,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],...
		'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,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],...
		'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,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],...
		'Mask Entries','0.1\/0\/5e6\/200\/''y-/g-/r-/w:/m*/ro/b+''\/')


%     Finished composite block ['p1(yel)',13,'p2(green)',13,'p3(red)'].

set_param([sys,'/',['p1(yel)',13,'p2(green)',13,'p3(red)']],...
		'position',[425,200,455,240])


%     Subsystem  'A'.

new_system([sys,'/','A'])
set_param([sys,'/','A'],'Location',[204,439,481,575])

add_block('built-in/Outport',[sys,'/','A/A'])
set_param([sys,'/','A/A'],...
		'position',[205,40,225,60])

add_block('built-in/Gain',[sys,'/','A/Gain'])
set_param([sys,'/','A/Gain'],...
		'hide name',0,...
		'Gain','0.03',...
		'position',[95,32,150,68])

add_block('built-in/Clock',[sys,'/','A/Clock'])
set_param([sys,'/','A/Clock'],...
		'position',[40,40,60,60])
add_line([sys,'/','A'],[155,50;200,50])
add_line([sys,'/','A'],[65,50;90,50])
set_param([sys,'/','A'],...
		'Mask Display','plot(0,0,100,100,[98,0],[96,0])',...
		'Mask Type','Ramp')


%     Finished composite block 'A'.

set_param([sys,'/','A'],...
		'position',[25,186,65,214])

add_block('built-in/From Workspace',[sys,'/','Q'])
set_param([sys,'/','Q'],...
		'matl_expr','[T'', Q'']',...
		'Mask Display','plot(T,Q)',...
		'Mask Type','Look-up Table',...
		'Mask Dialogue','Input Flow|Time Values (t):|Flow Values(Q):',...
		'Mask Translate','T=@1;Q=@2;')
set_param([sys,'/','Q'],...
		'Mask Entries','[0        .04     .04     .05    .05     .1]\/[.125   .125     0        0    .125    .125]\/',...
		'position',[20,127,60,153])


%     Subsystem  'Hit Crossing'.

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

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

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

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

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

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

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

add_block('built-in/Constant',[sys,'/','Hit Crossing/Constant'])
set_param([sys,'/','Hit Crossing/Constant'],...
		'Value','0',...
		'position',[235,125,285,145])
add_line([sys,'/','Hit Crossing'],[385,95;415,95;415,230;305,230;305,95;345,95])
add_line([sys,'/','Hit Crossing'],[290,135;345,135])
add_line([sys,'/','Hit Crossing'],[75,45;185,45])
add_line([sys,'/','Hit Crossing'],[290,55;345,55])
add_line([sys,'/','Hit Crossing'],[90,90;145,90;145,60;185,60])
add_line([sys,'/','Hit Crossing'],[225,55;260,55])
set_param([sys,'/','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,'/','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,'/','Hit Crossing'],...
		'Mask Translate','cross=@1; tol=@2;dvec=-.3:.03:(pi+.3);')
set_param([sys,'/','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,'/','Hit Crossing'],...
		'Mask Entries','0.01\/1e-4\/')


%     Finished composite block 'Hit Crossing'.

set_param([sys,'/','Hit Crossing'],...
		'position',[110,50,150,90])


%     Subsystem  ['q1(yel)',13,'q2(green)'].

new_system([sys,'/',['q1(yel)',13,'q2(green)']])
set_param([sys,'/',['q1(yel)',13,'q2(green)']],'Location',[0,59,274,252])

add_block('built-in/S-Function',[sys,'/',['q1(yel)',13,'q2(green)/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['q1(yel)',13,'q2(green)/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,'/',['q1(yel)',13,'q2(green)/x']])
set_param([sys,'/',['q1(yel)',13,'q2(green)/x']],...
		'position',[65,55,85,75])
add_line([sys,'/',['q1(yel)',13,'q2(green)']],[90,65;125,65])
set_param([sys,'/',['q1(yel)',13,'q2(green)']],...
		'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,'/',['q1(yel)',13,'q2(green)']],...
		'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,'/',['q1(yel)',13,'q2(green)']],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/',['q1(yel)',13,'q2(green)']],...
		'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,'/',['q1(yel)',13,'q2(green)']],...
		'Mask Entries','0.1\/-0.05\/0.2\/200\/''y-/g-/c-./w:/m*/ro/b+''\/')


%     Finished composite block ['q1(yel)',13,'q2(green)'].

set_param([sys,'/',['q1(yel)',13,'q2(green)']],...
		'position',[425,120,455,160])


%     Subsystem  'Subsystem2'.

new_system([sys,'/','Subsystem2'])
set_param([sys,'/','Subsystem2'],'Location',[486,613,757,820])
set_param([sys,'/','Subsystem2'],...
		'Mask Display','Double click to\nrun Simulation\nfor 0.1 seconds',...
		'Mask Type','Button')
set_param([sys,'/','Subsystem2'],...
		'Mask Dialogue','eval(''tout=rk45(get_param,[1e-5,0.1],[],[1e-4,1e-5,0.005]);set(gcf,''''position'''',get(gcf,''''position'''')+[50 -50 0 0])'')')


%     Finished composite block 'Subsystem2'.

set_param([sys,'/','Subsystem2'],...
		'BackGround',5,...
		'hide name',0,...
		'position',[25,320,156,390])


%     Subsystem  'Subsystem1'.

new_system([sys,'/','Subsystem1'])
set_param([sys,'/','Subsystem1'],'Location',[486,613,757,820])
set_param([sys,'/','Subsystem1'],...
		'Mask Display','Double click to\nsee 4 cylinder model.',...
		'Mask Type','Button',...
		'Mask Dialogue','eval(''hydcyl4'');')


%     Finished composite block 'Subsystem1'.

set_param([sys,'/','Subsystem1'],...
		'BackGround',5,...
		'hide name',0,...
		'position',[400,320,531,390])


%     Subsystem  ['Hydraulic',13,'cylinder',13,'model'].

new_system([sys,'/',['Hydraulic',13,'cylinder',13,'model']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model']],'Location',[57,353,444,581])


%     Subsystem  ['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model'].

new_system([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],'Location',[37,67,743,563])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2']],...
		'Port','4',...
		'position',[500,260,520,280])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1']],...
		'position',[660,210,680,230])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p1']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p1']],...
		'Port','3',...
		'position',[380,290,400,310])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q2']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q2']],...
		'Port','2',...
		'position',[140,245,160,265])

add_block('built-in/Sum',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2=p1+-f(q1)']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2=p1+-f(q1)']],...
		'inputs','-+',...
		'position',[435,244,455,291])

add_block('built-in/Inport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Q']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Q']],...
		'position',[50,300,65,320])

add_block('built-in/Sum',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q2=Q-q1']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q2=Q-q1']],...
		'inputs','-+',...
		'position',[90,274,110,321])

add_block('built-in/Gain',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p1=q2//Clam2']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p1=q2//Clam2']],...
		'Gain','1/Clam2',...
		'position',[155,283,230,317])

add_block('built-in/Inport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/A']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/A']],...
		'Port','2',...
		'position',[50,185,65,205])

add_block('built-in/Mux',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1,A']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1,A']],...
		'hide name',0,...
		'inputs','2',...
		'Mask Display','q1\n\nA',...
		'position',[85,158,100,207])

add_block('built-in/Gain',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/is flow going backwards?']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/is flow going backwards?']],...
		'Gain','-1',...
		'position',[280,228,315,262])

add_block('built-in/Constant',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Constant']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Constant']],...
		'Value','Ac*Ac/K',...
		'position',[10,415,80,445])

add_block('built-in/Mux',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p3, q1']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p3, q1']],...
		'hide name',0,...
		'inputs','3',...
		'Mask Display','p3\nq1\nCon',...
		'position',[120,395,150,435])

add_block('built-in/Fcn',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/f(q1,p3)']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/f(q1,p3)']],...
		'Expr','u[2]/(u[3]+(V0+u[3]*u[1])/beta)',...
		'position',[165,403,365,427])

add_block('built-in/Integrator',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/int p3']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/int p3']],...
		'Initial','1e-8',...
		'position',[380,405,400,425])

add_block('built-in/Sum',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2-p3']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2-p3']],...
		'inputs','+-',...
		'position',[500,311,520,364])

add_block('built-in/Gain',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1=Clam1*(p2-p3)']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1=Clam1*(p2-p3)']],...
		'Gain','Clam1',...
		'position',[555,322,620,358])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1-flow to cylinder']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1-flow to cylinder']],...
		'position',[560,26,565,31])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2-pressure downstream of orifice']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p2-pressure downstream of orifice']],...
		'position',[605,86,610,91])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p3-pressure in cylinder']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p3-pressure in cylinder']],...
		'position',[575,106,580,111])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q2-flow diverted to reservoir']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q2-flow diverted to reservoir']],...
		'position',[585,46,590,51])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p1-pressure upstream of orifice']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p1-pressure upstream of orifice']],...
		'position',[595,65,600,70])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Outputs:']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Outputs:']],...
		'position',[530,5,535,10])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/A-variable orifice area']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/A-variable orifice area']],...
		'position',[125,50,130,55])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Q-source flow']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Q-source flow']],...
		'position',[105,30,110,35])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Inputs:']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Inputs:']],...
		'position',[90,10,95,15])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Hydraulic Cylinder Model']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Hydraulic Cylinder Model']],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18)
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/Hydraulic Cylinder Model']],...
		'position',[355,20,360,25])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/',13,'Modeled by Andy Grace,',13,'The MathWorks from equations ',13,'provided by General Motors.']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/',13,'Modeled by Andy Grace,',13,'The MathWorks from equations ',13,'provided by General Motors.']],...
		'position',[355,65,360,70])

add_block('built-in/Gain',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/spring -x']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/spring -x']],...
		'Gain','Ac/K',...
		'position',[450,394,495,436])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p3']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/p3']],...
		'orientation',1,...
		'Port','5',...
		'position',[415,455,435,475])

add_block('built-in/Fcn',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume']],...
		'Expr','V0+Ac*u[1]',...
		'position',[515,406,590,424])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/V']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/V']],...
		'Port','6',...
		'position',[610,405,630,425])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume in cylinder']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume in cylinder']],...
		'position',[580,125,585,130])

add_block('built-in/Fcn',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/f(q1)']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/f(q1)']],...
		'Expr','(u[1]*u[1])*row/(2*Cd*u[2]*Cd*u[2])',...
		'position',[115,167,255,203])

add_block('built-in/Switch',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1>0?']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model/q1>0?']],...
		'position',[365,219,395,251])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[235,300;356,300;356,280;430,280])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[70,195;80,195])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[105,185;110,185])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[400,235;411,235;411,255;430,255])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[85,430;115,430])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[155,415;160,415])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[370,415;375,415])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[405,415;416,415;416,373;96,373;96,400;115,400])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[405,415;425,415;425,450])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[260,185;265,185;275,245])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[460,270;485,270;495,325])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[405,415;416,415;416,350;495,350])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[525,340;550,340])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[320,245;360,245])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[260,185;350,185;360,225])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[115,300;150,300])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[70,310;85,310])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[355,300;375,300])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[125,300;135,255])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[625,340;645,340;645,150;30,150;30,285;85,285])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[625,340;645,340;645,485;95,485;95,415;115,415])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[625,340;645,340;655,220])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[485,270;495,270])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[30,170;80,170])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[405,415;445,415])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[500,415;510,415])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[595,415;605,415])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],[333,150;333,235;360,235])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Display','   q1\n\n   q2\n\n   p1\n\n   p2\n\n   p3\n\n   V',...
		'Mask Type','Hydraulic cylinder')
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Dialogue','Hydraulic cylinder block. Unmask this block to see how it works.|Cd:|row:|[Clam1,Clam2]:|beta:|Ac:|[K,V0]:')
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Translate','Cd = @1; row = @2; Clam1 = @3(1); Clam2 = @3(2); beta = @4; Ac = @5; K = @6(1); V0 = @6(2);')
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Entries','0.61\/800\/[2e-7, 3e-8]\/700e6\/0.01\/[500000, 0.025]\/')


%     Finished composite block ['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model'].

set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Hydraulic ',13,'cylinder ',13,'model']],...
		'position',[90,30,130,185])

add_block('built-in/Inport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/A']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/A']],...
		'Port','2',...
		'position',[25,135,40,155])

add_block('built-in/Inport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Q']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Q']],...
		'position',[25,60,40,80])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/q']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/q']],...
		'position',[315,50,335,70])

add_block('built-in/Mux',[sys,'/',['Hydraulic',13,'cylinder',13,'model/p1, p2, p3']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/p1, p2, p3']],...
		'inputs','3',...
		'position',[240,83,275,157])

add_block('built-in/Outport',[sys,'/',['Hydraulic',13,'cylinder',13,'model/p']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/p']],...
		'Port','2',...
		'position',[315,110,335,130])

add_block('built-in/Mux',[sys,'/',['Hydraulic',13,'cylinder',13,'model/q1,q2']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/q1,q2']],...
		'move name',0,...
		'inputs','2',...
		'position',[240,34,275,81])

add_block('built-in/Note',[sys,'/',['Hydraulic',13,'cylinder',13,'model/Unmask the Hydraulic Cylinder model',13,'block to see how the implicit loop was',13,'formed. Then Mask to recover last mask.']])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model/Unmask the Hydraulic Cylinder model',13,'block to see how the implicit loop was',13,'formed. Then Mask to recover last mask.']],...
		'position',[260,170,265,175])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[45,70;85,70])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[45,145;85,145])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[280,60;310,60])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[280,120;310,120])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[135,45;235,45])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[135,70;235,70])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[135,95;235,95])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[135,120;235,120])
add_line([sys,'/',['Hydraulic',13,'cylinder',13,'model']],[135,145;235,145])
set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model']],...
		'Mask Display','plot(0,0,100,100,[90,47,70,70,90,47,47,47,10],[10,10,10,90,90,90,50,50,50],[47,47],[50,10])')


%     Finished composite block ['Hydraulic',13,'cylinder',13,'model'].

set_param([sys,'/',['Hydraulic',13,'cylinder',13,'model']],...
		'position',[260,124,295,186])

add_block('built-in/Note',[sys,'/','Hydraulic Cylinder Model'])
set_param([sys,'/','Hydraulic Cylinder Model'],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18,...
		'position',[270,5,275,10])
add_line(sys,[65,140;80,140;80,70;105,70])
add_line(sys,[300,170;355,170;355,220;420,220])
add_line(sys,[65,140;255,140])
add_line(sys,[70,200;155,200;155,170;255,170])
add_line(sys,[300,140;420,140])

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
