function [ret,x0,str,ts,xts]=hydrod(t,x,u,flag);
%HYDROD	is the M-file description of the SIMULINK system named HYDROD.
%	The block-diagram can be displayed by typing: HYDROD.
%
%	SYS=HYDROD(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 HYDROD 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 HYDROD with a FLAG of zero:
%	[SIZES]=HYDROD([],[],[],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',[96,84,776,510])
     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  '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-6\/')


%     Finished composite block 'Hit Crossing'.

set_param([sys,'/','Hit Crossing'],...
		'position',[95,115,135,155])


%     Subsystem  'A'.

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

add_block('built-in/Clock',[sys,'/','A/Clock'])
set_param([sys,'/','A/Clock'],...
		'position',[40,40,60,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/Outport',[sys,'/','A/A'])
set_param([sys,'/','A/A'],...
		'position',[205,40,225,60])
add_line([sys,'/','A'],[65,50;90,50])
add_line([sys,'/','A'],[155,50;200,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',[30,191,70,219])


%     Subsystem  'Fa (yel) Fb(green)'.

new_system([sys,'/','Fa (yel) Fb(green)'])
set_param([sys,'/','Fa (yel) Fb(green)'],'Location',[0,59,274,252])

add_block('built-in/Inport',[sys,'/','Fa (yel) Fb(green)/x'])
set_param([sys,'/','Fa (yel) Fb(green)/x'],...
		'position',[65,55,85,75])

add_block('built-in/S-Function',[sys,'/',['Fa (yel) Fb(green)/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Fa (yel) Fb(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_line([sys,'/','Fa (yel) Fb(green)'],[90,65;125,65])
set_param([sys,'/','Fa (yel) Fb(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,'/','Fa (yel) Fb(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,'/','Fa (yel) Fb(green)'],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/','Fa (yel) Fb(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,'/','Fa (yel) Fb(green)'],...
		'Mask Entries','0.1\/0\/6e4\/200\/''y-/g-/r-/w:/m*/ro/b+''\/')


%     Finished composite block 'Fa (yel) Fb(green)'.

set_param([sys,'/','Fa (yel) Fb(green)'],...
		'position',[530,315,560,355])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'inputs','2',...
		'position',[455,316,485,349])

add_block('built-in/Constant',[sys,'/','Constant'])
set_param([sys,'/','Constant'],...
		'hide name',0,...
		'Value','0.125',...
		'position',[250,68,290,92])

add_block('built-in/Note',[sys,'/','Fa'])
set_param([sys,'/','Fa'],...
		'position',[510,235,515,240])

add_block('built-in/Note',[sys,'/','Fb'])
set_param([sys,'/','Fb'],...
		'position',[510,190,515,195])


%     Subsystem  'Rod'.

new_system([sys,'/','Rod'])
set_param([sys,'/','Rod'],'Location',[176,536,1022,783])

add_block('built-in/Sum',[sys,'/','Rod/Fa + Fb'])
set_param([sys,'/','Rod/Fa + Fb'],...
		'position',[80,55,100,75])

add_block('built-in/Gain',[sys,'/','Rod/Gain1'])
set_param([sys,'/','Rod/Gain1'],...
		'hide name',0,...
		'Gain','1/m',...
		'position',[145,46,180,84])

add_block('built-in/Inport',[sys,'/','Rod/Fa'])
set_param([sys,'/','Rod/Fa'],...
		'Port','2',...
		'position',[15,60,35,80])

add_block('built-in/Inport',[sys,'/','Rod/Fb'])
set_param([sys,'/','Rod/Fb'],...
		'position',[15,10,35,30])

add_block('built-in/Integrator',[sys,'/','Rod/zdot'])
set_param([sys,'/','Rod/zdot'],...
		'position',[210,55,230,75])

add_block('built-in/Outport',[sys,'/','Rod/za'])
set_param([sys,'/','Rod/za'],...
		'Port','3',...
		'position',[605,60,625,80])

add_block('built-in/Sum',[sys,'/','Rod/zdot -L*theta//2'])
set_param([sys,'/','Rod/zdot -L*theta//2'],...
		'inputs','+-',...
		'position',[480,60,500,80])

add_block('built-in/Outport',[sys,'/','Rod/zadot'])
set_param([sys,'/','Rod/zadot'],...
		'Port','4',...
		'position',[605,3,625,27])

add_block('built-in/Gain',[sys,'/','Rod/Gain3'])
set_param([sys,'/','Rod/Gain3'],...
		'hide name',0,...
		'Gain','L/2',...
		'position',[365,169,400,201])

add_block('built-in/Integrator',[sys,'/','Rod/thetadot'])
set_param([sys,'/','Rod/thetadot'],...
		'position',[210,175,230,195])

add_block('built-in/Sum',[sys,'/','Rod/Fb- Fa'])
set_param([sys,'/','Rod/Fb- Fa'],...
		'inputs','-+',...
		'position',[80,175,100,195])

add_block('built-in/Integrator',[sys,'/','Rod/z'])
set_param([sys,'/','Rod/z'],...
		'position',[315,55,335,75])

add_block('built-in/Integrator',[sys,'/','Rod/theta'])
set_param([sys,'/','Rod/theta'],...
		'position',[305,175,325,195])

add_block('built-in/Sum',[sys,'/','Rod/z+L*theta//2'])
set_param([sys,'/','Rod/z+L*theta//2'],...
		'position',[480,110,500,130])

add_block('built-in/Outport',[sys,'/','Rod/zb'])
set_param([sys,'/','Rod/zb'],...
		'position',[605,110,625,130])

add_block('built-in/Gain',[sys,'/','Rod/Gain2'])
set_param([sys,'/','Rod/Gain2'],...
		'hide name',0,...
		'Gain','L/(2*Izz)',...
		'position',[145,166,180,204])

add_block('built-in/Gain',[sys,'/','Rod/Gain4'])
set_param([sys,'/','Rod/Gain4'],...
		'hide name',0,...
		'Gain','L/2',...
		'position',[310,88,340,122])

add_block('built-in/Sum',[sys,'/','Rod/z-L*theta//2'])
set_param([sys,'/','Rod/z-L*theta//2'],...
		'inputs','+-',...
		'position',[475,5,495,25])

add_block('built-in/Outport',[sys,'/','Rod/zbdot'])
set_param([sys,'/','Rod/zbdot'],...
		'Port','2',...
		'position',[605,165,625,185])

add_block('built-in/Sum',[sys,'/','Rod/zdot + L*thetadot//2'])
set_param([sys,'/','Rod/zdot + L*thetadot//2'],...
		'position',[480,165,500,185])

add_block('built-in/Mux',[sys,'/','Rod/Mux1'])
set_param([sys,'/','Rod/Mux1'],...
		'hide name',0,...
		'inputs','2',...
		'position',[360,134,395,161])

add_block('built-in/Mux',[sys,'/','Rod/Mux2'])
set_param([sys,'/','Rod/Mux2'],...
		'hide name',0,...
		'inputs','2',...
		'position',[360,24,395,51])

add_block('built-in/Mux',[sys,'/','Rod/Mux3'])
set_param([sys,'/','Rod/Mux3'],...
		'hide name',0,...
		'inputs','[2 2]',...
		'position',[710,34,745,61])


%     Subsystem  ['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)'].

new_system([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']])
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],'Location',[0,59,274,252])

add_block('built-in/S-Function',[sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts, dt')
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'position',[130,55,180,75])

add_block('built-in/Inport',[sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)/x']])
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)/x']],...
		'position',[65,55,85,75])
add_line([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],[90,65;125,65])
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'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])')
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'Mask Type','Storage scope.')
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'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,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'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,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'Mask Entries','0.1\/0\/3\/200\/''y-/g-/r-/b-/m*/ro/b+''\/')


%     Finished composite block ['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)'].

set_param([sys,'/',['Rod/zdot (yel)',13,'z(green)',13,'thetadot(red)',13,'theta(blue)']],...
		'position',[775,37,805,63])
add_line([sys,'/','Rod'],[105,65;140,65])
add_line([sys,'/','Rod'],[185,65;205,65])
add_line([sys,'/','Rod'],[235,65;310,65])
add_line([sys,'/','Rod'],[40,20;50,20;50,60;75,60])
add_line([sys,'/','Rod'],[340,65;475,65])
add_line([sys,'/','Rod'],[40,70;75,70])
add_line([sys,'/','Rod'],[50,60;50,190;75,190])
add_line([sys,'/','Rod'],[60,70;60,180;75,180])
add_line([sys,'/','Rod'],[105,185;140,185])
add_line([sys,'/','Rod'],[185,185;205,185])
add_line([sys,'/','Rod'],[235,185;300,185])
add_line([sys,'/','Rod'],[330,185;360,185])
add_line([sys,'/','Rod'],[405,185;435,185;435,75;475,75])
add_line([sys,'/','Rod'],[505,70;600,70])
add_line([sys,'/','Rod'],[255,65;255,10;470,10])
add_line([sys,'/','Rod'],[345,105;425,105;425,20;470,20])
add_line([sys,'/','Rod'],[500,15;600,15])
add_line([sys,'/','Rod'],[270,185;270,105;305,105])
add_line([sys,'/','Rod'],[435,125;475,125])
add_line([sys,'/','Rod'],[505,120;600,120])
add_line([sys,'/','Rod'],[395,65;395,115;475,115])
add_line([sys,'/','Rod'],[255,65;255,170;475,170])
add_line([sys,'/','Rod'],[505,175;600,175])
add_line([sys,'/','Rod'],[425,105;425,180;475,180])
add_line([sys,'/','Rod'],[340,185;340,155;355,155])
add_line([sys,'/','Rod'],[270,140;355,140])
add_line([sys,'/','Rod'],[400,150;695,150;705,55])
add_line([sys,'/','Rod'],[340,65;340,45;355,45])
add_line([sys,'/','Rod'],[335,10;335,30;355,30])
add_line([sys,'/','Rod'],[400,40;705,40])
add_line([sys,'/','Rod'],[750,50;770,50])
set_param([sys,'/','Rod'],...
		'Mask Display','plot(0,0,100,100,[10,75,84,17,10],[18,91,81,9,17],[16,7],[25,39],[17,16,16,12],[30,25,25,25],[87,76],[60,71],[76,76,80],[66,72,71],[99,2],[50,50],[68,68,67,65],[50,54,57,60])',...
		'Mask Type','Rod')
set_param([sys,'/','Rod'],...
		'Mask Dialogue','Rod  Model| m:|L|Izz:',...
		'Mask Translate','m = @1; L = @2; Izz = @3;',...
		'Mask Entries','2500\/5\/100\/')


%     Finished composite block 'Rod'.

set_param([sys,'/','Rod'],...
		'position',[535,185,585,275])

add_block('built-in/Note',[sys,'/','2 CYLINDER  MODEL WITH CONNECTING ROD'])
set_param([sys,'/','2 CYLINDER  MODEL WITH CONNECTING ROD'],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18,...
		'position',[340,10,345,15])

add_block('built-in/Note',[sys,'/',['Unmask the Subsystems and Rod to see',13,'how they are implemented.']])
set_param([sys,'/',['Unmask the Subsystems and Rod to see',13,'how they are implemented.']],...
		'position',[520,75,525,80])


%     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',[20,310,151,380])

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',[25,67,65,93])


%     Subsystem  'Subsystem A'.

new_system([sys,'/','Subsystem A'])
set_param([sys,'/','Subsystem A'],'Location',[380,489,767,717])

add_block('built-in/Inport',[sys,'/','Subsystem A/Q'])
set_param([sys,'/','Subsystem A/Q'],...
		'position',[15,35,30,55])


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

new_system([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],'Location',[498,102,1304,655])

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

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/',13,'Hydraulic Cylinder Model',13,'for connection to rod']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/',13,'Hydraulic Cylinder Model',13,'for connection to rod']],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18)
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/',13,'Hydraulic Cylinder Model',13,'for connection to rod']],...
		'position',[375,20,380,25])

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

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

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

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/Outputs:']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/Outputs:']],...
		'position',[580,10,585,15])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p1-pressure upstream of orifice']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p1-pressure upstream of orifice']],...
		'position',[640,70,645,75])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q2-flow diverted to reservoir']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q2-flow diverted to reservoir']],...
		'position',[635,51,640,56])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p3-pressure in cylinder']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p3-pressure in cylinder']],...
		'position',[620,111,625,116])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2-pressure downstream of orifice']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2-pressure downstream of orifice']],...
		'position',[645,91,650,96])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1-flow to cylinder']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1-flow to cylinder']],...
		'position',[610,31,615,36])

add_block('built-in/Gain',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1=Clam1*(p2-p3)']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1=Clam1*(p2-p3)']],...
		'Gain','Clam1',...
		'position',[645,347,670,373])

add_block('built-in/Sum',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2-p3']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2-p3']],...
		'inputs','+-',...
		'position',[575,331,595,384])

add_block('built-in/Fcn',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/f(q1)']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/f(q1)']],...
		'Expr','(u[1]*u[1])*row/(2*Cd*u[2]*Cd*u[2])',...
		'position',[145,181,325,199])

add_block('built-in/Integrator',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/int p3']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/int p3']],...
		'Initial','1e-8',...
		'position',[430,425,450,445])

add_block('built-in/Switch',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1>0?']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1>0?']],...
		'position',[420,224,450,256])

add_block('built-in/Gain',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/is flow going backwards?']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/is flow going backwards?']],...
		'Gain','-1',...
		'position',[350,237,375,263])

add_block('built-in/Mux',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1,A']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1,A']],...
		'hide name',0,...
		'inputs','2',...
		'Mask Display','q1\n\nA',...
		'position',[110,163,125,212])

add_block('built-in/Inport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/A']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/A']],...
		'Port','2',...
		'position',[45,190,60,210])

add_block('built-in/Gain',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p1=q2//Clam2']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p1=q2//Clam2']],...
		'Gain','1/Clam2',...
		'position',[205,303,280,337])

add_block('built-in/Sum',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q2=Q-q1']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q2=Q-q1']],...
		'inputs','-+',...
		'position',[135,294,155,341])

add_block('built-in/Inport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/Q']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/Q']],...
		'position',[35,320,50,340])

add_block('built-in/Sum',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2=p1+-f(q1)']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2=p1+-f(q1)']],...
		'inputs','-+',...
		'position',[490,264,510,311])

add_block('built-in/Outport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q2']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q2']],...
		'Port','2',...
		'position',[190,250,210,270])

add_block('built-in/Outport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p1']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p1']],...
		'Port','3',...
		'position',[420,310,440,330])

add_block('built-in/Outport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/q1']],...
		'position',[760,220,780,240])

add_block('built-in/Outport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p2']],...
		'Port','4',...
		'position',[565,280,585,300])

add_block('built-in/Fcn',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dp3//dt']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dp3//dt']],...
		'Expr','(beta/u[1])*(u[2]-u[3])',...
		'position',[300,422,410,448])

add_block('built-in/Fcn',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume1']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume1']],...
		'Expr','V0+Ac*u[1]',...
		'position',[110,386,185,404])

add_block('built-in/Inport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/z']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/z']],...
		'Port','3',...
		'position',[35,385,55,405])

add_block('built-in/Mux',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p3, q2']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p3, q2']],...
		'hide name',0,...
		'inputs','3',...
		'Mask Display','V\nq1\ndv',...
		'position',[240,415,270,455])

add_block('built-in/Gain',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dv//dt']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dv//dt']],...
		'Gain','Ac',...
		'position',[80,434,110,466])

add_block('built-in/Inport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dz//dt']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dz//dt']],...
		'Port','4',...
		'position',[35,440,55,460])

add_block('built-in/Outport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p3']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/p3']],...
		'orientation',1,...
		'Port','5',...
		'position',[465,465,485,485])

add_block('built-in/Gain',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/Force']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/Force']],...
		'Gain','Ac',...
		'position',[540,419,570,451])

add_block('built-in/Outport',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/F']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/F']],...
		'Port','6',...
		'position',[595,425,615,445])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/z-displacement of cg of rod']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/z-displacement of cg of rod']],...
		'position',[140,70,145,75])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dz//dt-rate of change of rod displacement']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/dz//dt-rate of change of rod displacement']],...
		'position',[170,90,175,95])

add_block('built-in/Note',[sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/F-force from cylinder']])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model/F-force from cylinder']],...
		'position',[615,130,620,135])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,150;85,150;85,305;130,305])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[85,175;105,175])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[515,290;536,290;536,345;570,345])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[535,290;560,290])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,150;385,150;385,240;415,240])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,230;755,230])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,540;120,540;120,435;235,435])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[160,320;200,320])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[175,320;185,260])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[285,320;381,320;381,300;485,300])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[380,320;415,320])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[55,330;130,330])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[330,190;405,190;415,230])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[380,250;415,250])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[600,360;640,360])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[455,435;476,435;476,370;570,370])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[330,190;335,190;345,250])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[455,435;475,435;475,460])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[415,435;425,435])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[275,435;295,435])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[455,240;466,240;466,275;485,275])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[130,190;140,190])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[65,200;105,200])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[60,395;105,395])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[190,395;205,395;205,420;235,420])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[60,450;75,450])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[115,450;235,450])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[455,435;535,435])
add_line([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],[575,435;590,435])
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Display','   q1\n\n   q2\n\n   p1\n\n   p2\n\n   p3\n\n  F',...
		'Mask Type','Hydraulic Cylinder')
set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Dialogue','Hydraulic cylinder model connected to rod.|Cd:|row:|[Clam1,Clam2]:|beta:|Ac:|[K,V0]:')
set_param([sys,'/',['Subsystem A/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,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Entries','.61\/800\/[2e-7, 3e-8]\/700e6\/.01\/[500000,.025]\/')


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

set_param([sys,'/',['Subsystem A/Hydraulic ',13,'cylinder ',13,'model']],...
		'position',[105,50,145,170])

add_block('built-in/Inport',[sys,'/','Subsystem A/A'])
set_param([sys,'/','Subsystem A/A'],...
		'Port','2',...
		'position',[15,80,30,100])

add_block('built-in/Inport',[sys,'/','Subsystem A/z'])
set_param([sys,'/','Subsystem A/z'],...
		'Port','3',...
		'position',[15,120,30,140])

add_block('built-in/Inport',[sys,'/','Subsystem A/dz//dt'])
set_param([sys,'/','Subsystem A/dz//dt'],...
		'Port','4',...
		'position',[15,160,30,180])

add_block('built-in/Outport',[sys,'/','Subsystem A/F'])
set_param([sys,'/','Subsystem A/F'],...
		'position',[255,150,275,170])

add_block('built-in/Note',[sys,'/',['Subsystem A/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,'/',['Subsystem A/Unmask the Hydraulic Cylinder model',13,'block to see how the implicit loop was',13,'formed. Then Mask to recover last mask.']],...
		'position',[275,60,280,65])
add_line([sys,'/','Subsystem A'],[35,90;60,90;60,95;100,95])
add_line([sys,'/','Subsystem A'],[35,45;60,45;60,65;100,65])
add_line([sys,'/','Subsystem A'],[35,170;60,170;60,155;100,155])
add_line([sys,'/','Subsystem A'],[35,130;60,130;60,125;100,125])
add_line([sys,'/','Subsystem A'],[150,160;250,160])
set_param([sys,'/','Subsystem A'],...
		'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 'Subsystem A'.

set_param([sys,'/','Subsystem A'],...
		'position',[250,231,285,279])


%     Subsystem  'Subsystem B'.

new_system([sys,'/','Subsystem B'])
set_param([sys,'/','Subsystem B'],'Location',[380,489,767,717])

add_block('built-in/Note',[sys,'/',['Subsystem B/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,'/',['Subsystem B/Unmask the Hydraulic Cylinder model',13,'block to see how the implicit loop was',13,'formed. Then Mask to recover last mask.']],...
		'position',[275,60,280,65])

add_block('built-in/Outport',[sys,'/','Subsystem B/F'])
set_param([sys,'/','Subsystem B/F'],...
		'position',[255,150,275,170])

add_block('built-in/Inport',[sys,'/','Subsystem B/dz//dt'])
set_param([sys,'/','Subsystem B/dz//dt'],...
		'Port','4',...
		'position',[15,160,30,180])

add_block('built-in/Inport',[sys,'/','Subsystem B/z'])
set_param([sys,'/','Subsystem B/z'],...
		'Port','3',...
		'position',[15,120,30,140])

add_block('built-in/Inport',[sys,'/','Subsystem B/A'])
set_param([sys,'/','Subsystem B/A'],...
		'Port','2',...
		'position',[15,80,30,100])


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

new_system([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],'Location',[498,102,1304,655])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/F-force from cylinder']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/F-force from cylinder']],...
		'position',[615,130,620,135])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dz//dt-rate of change of rod displacement']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dz//dt-rate of change of rod displacement']],...
		'position',[170,90,175,95])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/z-displacement of cg of rod']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/z-displacement of cg of rod']],...
		'position',[140,70,145,75])

add_block('built-in/Outport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/F']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/F']],...
		'Port','6',...
		'position',[595,425,615,445])

add_block('built-in/Gain',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/Force']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/Force']],...
		'Gain','Ac',...
		'position',[540,419,570,451])

add_block('built-in/Outport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p3']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p3']],...
		'orientation',1,...
		'Port','5',...
		'position',[465,465,485,485])

add_block('built-in/Inport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dz//dt']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dz//dt']],...
		'Port','4',...
		'position',[35,440,55,460])

add_block('built-in/Gain',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dv//dt']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dv//dt']],...
		'Gain','Ac',...
		'position',[80,434,110,466])

add_block('built-in/Mux',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p3, q2']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p3, q2']],...
		'hide name',0,...
		'inputs','3',...
		'Mask Display','V\nq1\ndv',...
		'position',[240,415,270,455])

add_block('built-in/Inport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/z']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/z']],...
		'Port','3',...
		'position',[35,385,55,405])

add_block('built-in/Fcn',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume1']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/V-fluid volume1']],...
		'Expr','V0+Ac*u[1]',...
		'position',[110,386,185,404])

add_block('built-in/Fcn',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dp3//dt']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/dp3//dt']],...
		'Expr','(beta/u[1])*(u[2]-u[3])',...
		'position',[300,422,410,448])

add_block('built-in/Outport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2']],...
		'Port','4',...
		'position',[565,280,585,300])

add_block('built-in/Outport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1']],...
		'position',[760,220,780,240])

add_block('built-in/Outport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p1']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p1']],...
		'Port','3',...
		'position',[420,310,440,330])

add_block('built-in/Outport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q2']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q2']],...
		'Port','2',...
		'position',[190,250,210,270])

add_block('built-in/Sum',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2=p1+-f(q1)']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2=p1+-f(q1)']],...
		'inputs','-+',...
		'position',[490,264,510,311])

add_block('built-in/Inport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/Q']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/Q']],...
		'position',[35,320,50,340])

add_block('built-in/Sum',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q2=Q-q1']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q2=Q-q1']],...
		'inputs','-+',...
		'position',[135,294,155,341])

add_block('built-in/Gain',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p1=q2//Clam2']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p1=q2//Clam2']],...
		'Gain','1/Clam2',...
		'position',[205,303,280,337])

add_block('built-in/Inport',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/A']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/A']],...
		'Port','2',...
		'position',[45,190,60,210])

add_block('built-in/Mux',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1,A']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1,A']],...
		'hide name',0,...
		'inputs','2',...
		'Mask Display','q1\n\nA',...
		'position',[110,163,125,212])

add_block('built-in/Gain',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/is flow going backwards?']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/is flow going backwards?']],...
		'Gain','-1',...
		'position',[350,237,375,263])

add_block('built-in/Switch',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1>0?']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1>0?']],...
		'position',[420,224,450,256])

add_block('built-in/Integrator',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/int p3']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/int p3']],...
		'Initial','1e-8',...
		'position',[430,425,450,445])

add_block('built-in/Fcn',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/f(q1)']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/f(q1)']],...
		'Expr','(u[1]*u[1])*row/(2*Cd*u[2]*Cd*u[2])',...
		'position',[145,181,325,199])

add_block('built-in/Sum',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2-p3']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2-p3']],...
		'inputs','+-',...
		'position',[575,331,595,384])

add_block('built-in/Gain',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1=Clam1*(p2-p3)']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1=Clam1*(p2-p3)']],...
		'Gain','Clam1',...
		'position',[645,347,670,373])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1-flow to cylinder']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q1-flow to cylinder']],...
		'position',[610,31,615,36])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2-pressure downstream of orifice']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p2-pressure downstream of orifice']],...
		'position',[645,91,650,96])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p3-pressure in cylinder']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p3-pressure in cylinder']],...
		'position',[620,111,625,116])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q2-flow diverted to reservoir']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/q2-flow diverted to reservoir']],...
		'position',[635,51,640,56])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p1-pressure upstream of orifice']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/p1-pressure upstream of orifice']],...
		'position',[640,70,645,75])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/Outputs:']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/Outputs:']],...
		'position',[580,10,585,15])

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

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

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

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/',13,'Hydraulic Cylinder Model',13,'for connection to rod']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/',13,'Hydraulic Cylinder Model',13,'for connection to rod']],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18)
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/',13,'Hydraulic Cylinder Model',13,'for connection to rod']],...
		'position',[375,20,380,25])

add_block('built-in/Note',[sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/',13,'Modeled by Andy Grace,',13,'The MathWorks from equations ',13,'provided by General Motors.']])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model/',13,'Modeled by Andy Grace,',13,'The MathWorks from equations ',13,'provided by General Motors.']],...
		'position',[375,65,380,70])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[575,435;590,435])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[455,435;535,435])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[115,450;235,450])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[60,450;75,450])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[190,395;205,395;205,420;235,420])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[60,395;105,395])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[65,200;105,200])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[130,190;140,190])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[455,240;466,240;466,275;485,275])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[275,435;295,435])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[415,435;425,435])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[455,435;475,435;475,460])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[330,190;335,190;345,250])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[455,435;476,435;476,370;570,370])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[600,360;640,360])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[380,250;415,250])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[330,190;405,190;415,230])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[55,330;130,330])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[285,320;381,320;381,300;485,300])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[380,320;415,320])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[160,320;200,320])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[175,320;185,260])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,540;120,540;120,435;235,435])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,230;755,230])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,150;385,150;385,240;415,240])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[515,290;536,290;536,345;570,345])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[535,290;560,290])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[675,360;725,360;725,150;85,150;85,305;130,305])
add_line([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],[85,175;105,175])
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Display','   q1\n\n   q2\n\n   p1\n\n   p2\n\n   p3\n\n  F',...
		'Mask Type','Hydraulic Cylinder')
set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Dialogue','Hydraulic cylinder model connected to rod.|Cd:|row:|[Clam1,Clam2]:|beta:|Ac:|[K,V0]:')
set_param([sys,'/',['Subsystem B/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,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],...
		'Mask Entries','.61\/700\/[1e-7, 2e-8]\/600e6\/.011\/[400000,.03]\/')


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

set_param([sys,'/',['Subsystem B/Hydraulic ',13,'cylinder ',13,'model']],...
		'position',[105,50,145,170])

add_block('built-in/Inport',[sys,'/','Subsystem B/Q'])
set_param([sys,'/','Subsystem B/Q'],...
		'position',[15,35,30,55])
add_line([sys,'/','Subsystem B'],[150,160;250,160])
add_line([sys,'/','Subsystem B'],[35,130;60,130;60,125;100,125])
add_line([sys,'/','Subsystem B'],[35,170;60,170;60,155;100,155])
add_line([sys,'/','Subsystem B'],[35,45;60,45;60,65;100,65])
add_line([sys,'/','Subsystem B'],[35,90;60,90;60,95;100,95])
set_param([sys,'/','Subsystem B'],...
		'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 'Subsystem B'.

set_param([sys,'/','Subsystem B'],...
		'position',[375,186,410,234])
add_line(sys,[70,80;160,80;160,240;245,240])
add_line(sys,[70,80;80,80;90,135])
add_line(sys,[75,205;170,205;170,250;245,250])
add_line(sys,[170,205;370,205])
add_line(sys,[290,255;530,255])
add_line(sys,[415,210;530,210])
add_line(sys,[590,200;640,200;640,160;360,160;370,215])
add_line(sys,[590,220;660,220;660,150;345,150;345,225;370,225])
add_line(sys,[590,240;660,240;660,400;195,400;195,260;245,260])
add_line(sys,[590,260;640,260;640,390;210,390;210,270;245,270])
add_line(sys,[295,80;335,80;335,195;370,195])
add_line(sys,[490,335;525,335])
add_line(sys,[440,255;450,325])
add_line(sys,[430,210;430,340;450,340])

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
