function [ret,x0,str,ts,xts]=s6_14(t,x,u,flag);
%S6_14	is the M-file description of the SIMULINK system named S6_14.
%	The block-diagram can be displayed by typing: S6_14.
%
%	SYS=S6_14(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 S6_14 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 S6_14 with a FLAG of zero:
%	[SIZES]=S6_14([],[],[],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',[22,100,613,428])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-23')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     't_d')
set_param(sys,'Min step size', 'Tc/10')
set_param(sys,'Max step size', 'Tc')
set_param(sys,'Relative error','1e-8')
set_param(sys,'Return vars',   '')


%     Subsystem  'Subsystem6'.

new_system([sys,'/','Subsystem6'])
set_param([sys,'/','Subsystem6'],'Location',[355,393414,500,393509])

add_block('built-in/Note',[sys,'/','Subsystem6/start'])
set_param([sys,'/','Subsystem6/start'],...
		'position',[55,45,60,50])
set_param([sys,'/','Subsystem6'],...
		'Mask Display','variables\ninitialization',...
		'Mask Dialogue','eval(''clear all;i6_14;'')')


%     Finished composite block 'Subsystem6'.

set_param([sys,'/','Subsystem6'],...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[5,5,80,41])

add_block('built-in/To Workspace',[sys,'/','To Workspace3'])
set_param([sys,'/','To Workspace3'],...
		'hide name',0,...
		'Font Name','Arial',...
		'mat-name','e',...
		'buffer','[5001,1,Ts]',...
		'position',[135,235,185,255])

add_block('built-in/From Workspace',[sys,'/',['From',13,'Workspace3']])
set_param([sys,'/',['From',13,'Workspace3']],...
		'hide name',0,...
		'Font Name','Arial',...
		'matl_expr','[T,dq_d]',...
		'position',[5,133,55,157])

add_block('built-in/Note',[sys,'/','sig'])
set_param([sys,'/','sig'],...
		'Font Name','Arial',...
		'position',[255,205,260,210])

add_block('built-in/Note',[sys,'/','dq_r'])
set_param([sys,'/','dq_r'],...
		'Font Name','Arial',...
		'position',[220,165,225,170])

add_block('built-in/Note',[sys,'/','ddq_r'])
set_param([sys,'/','ddq_r'],...
		'Font Name','Arial',...
		'position',[225,105,230,110])

add_block('built-in/Sum',[sys,'/','Sum5'])
set_param([sys,'/','Sum5'],...
		'hide name',0,...
		'Font Name','Arial',...
		'inputs','+-',...
		'position',[230,185,245,225])

add_block('built-in/From Workspace',[sys,'/',['From',13,'Workspace2']])
set_param([sys,'/',['From',13,'Workspace2']],...
		'hide name',0,...
		'Font Name','Arial',...
		'matl_expr','[T,ddq_d]',...
		'position',[5,82,55,108])

add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
		'hide name',0,...
		'Font Name','Arial',...
		'inputs','-+',...
		'position',[85,115,100,155])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space'])
set_param([sys,'/','Discrete State-Space'],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','Lam',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','Lam')
set_param([sys,'/','Discrete State-Space'],...
		'position',[120,119,150,151])


%     Subsystem  ['adaptive',13,'control'].

new_system([sys,'/',['adaptive',13,'control']])
set_param([sys,'/',['adaptive',13,'control']],'Location',[8,238,620,460])

add_block('built-in/Inport',[sys,'/',['adaptive',13,'control/q']])
set_param([sys,'/',['adaptive',13,'control/q']],...
		'Port','5',...
		'position',[5,55,25,75])

add_block('built-in/Fcn',[sys,'/',['adaptive',13,'control/Fcn']])
set_param([sys,'/',['adaptive',13,'control/Fcn']],...
		'hide name',0,...
		'Expr','cos(u(1))',...
		'position',[130,54,210,76])

add_block('built-in/Fcn',[sys,'/',['adaptive',13,'control/Fcn1']])
set_param([sys,'/',['adaptive',13,'control/Fcn1']],...
		'hide name',0,...
		'Expr','cos(u(2))',...
		'position',[130,79,210,101])

add_block('built-in/Fcn',[sys,'/',['adaptive',13,'control/Fcn2']])
set_param([sys,'/',['adaptive',13,'control/Fcn2']],...
		'hide name',0,...
		'Expr','sin(u(2))',...
		'position',[130,104,210,126])

add_block('built-in/Fcn',[sys,'/',['adaptive',13,'control/Fcn3']])
set_param([sys,'/',['adaptive',13,'control/Fcn3']],...
		'hide name',0,...
		'Expr','cos(u(1)+u(2))',...
		'position',[130,129,210,151])

add_block('built-in/Mux',[sys,'/',['adaptive',13,'control/Mux']])
set_param([sys,'/',['adaptive',13,'control/Mux']],...
		'hide name',0,...
		'inputs','[2;2;2;2;4;1]',...
		'position',[325,20,350,130])

add_block('built-in/State-Space',[sys,'/',['adaptive',13,'control/Matrix',13,'Gain1']])
set_param([sys,'/',['adaptive',13,'control/Matrix',13,'Gain1']],...
		'orientation',2,...
		'hide name',0,...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','1/K_ml',...
		'Mask Type','Matrix Gain')
set_param([sys,'/',['adaptive',13,'control/Matrix',13,'Gain1']],...
		'Mask Dialogue','Matrix Gain.|Gain matrix:',...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).')
set_param([sys,'/',['adaptive',13,'control/Matrix',13,'Gain1']],...
		'Mask Entries','1/K_ml\/',...
		'position',[480,144,535,176])

add_block('built-in/MATLAB Fcn',[sys,'/',['adaptive',13,'control/adaptive law']])
set_param([sys,'/',['adaptive',13,'control/adaptive law']],...
		'move name',0,...
		'MATLAB Fcn','adap',...
		'Output Width','3',...
		'Mask Display','adap',...
		'position',[435,60,495,90])

add_block('built-in/Discrete State-Space',[sys,'/',['adaptive',13,'control/Discrete State-Space3']])
set_param([sys,'/',['adaptive',13,'control/Discrete State-Space3']],...
		'hide name',0,...
		'A','0',...
		'B','0',...
		'C','zeros(13,1)',...
		'D','eye(13,13)',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','Sampler')
set_param([sys,'/',['adaptive',13,'control/Discrete State-Space3']],...
		'position',[365,60,415,90])

add_block('built-in/Discrete State-Space',[sys,'/',['adaptive',13,'control/Discrete State-Space4']])
set_param([sys,'/',['adaptive',13,'control/Discrete State-Space4']],...
		'hide name',0,...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','eye(2,2)',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','Sampler')
set_param([sys,'/',['adaptive',13,'control/Discrete State-Space4']],...
		'position',[40,50,90,80])


%     Subsystem  ['adaptive',13,'control/Discrete-Time',13,'Integrator1'].

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

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

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

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

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

add_block('built-in/Inport',[sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1/in_1']])
set_param([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1/in_1']],...
		'position',[25,70,45,90])
add_line([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],[265,95;315,95])
add_line([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],[285,95;285,165;120,165;120,110;145,110])
add_line([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],[185,95;205,95])
add_line([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],[50,80;75,80])
add_line([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],[115,80;145,80])
set_param([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],...
		'Mask Display','dpoly(Ts*[1 0],[1 -1],''z'')',...
		'Mask Type','Discrete-Time Integrator')
set_param([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],...
		'Mask Dialogue','Discrete-Time Integrator:|Initial Condition:|Sample Time:',...
		'Mask Translate','X0=@1;Ts=@2;')
set_param([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],...
		'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,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],...
		'Mask Entries','m_l0\/Tc\/')


%     Finished composite block ['adaptive',13,'control/Discrete-Time',13,'Integrator1'].

set_param([sys,'/',['adaptive',13,'control/Discrete-Time',13,'Integrator1']],...
		'orientation',2,...
		'hide name',0,...
		'position',[395,140,435,180])

add_block('built-in/To Workspace',[sys,'/',['adaptive',13,'control/To Workspace']])
set_param([sys,'/',['adaptive',13,'control/To Workspace']],...
		'hide name',0,...
		'mat-name','m_l',...
		'buffer','[5001,1,Ts]',...
		'position',[435,188,485,212])

add_block('built-in/Demux',[sys,'/',['adaptive',13,'control/Demux']])
set_param([sys,'/',['adaptive',13,'control/Demux']],...
		'hide name',0,...
		'outputs','[2;1]',...
		'position',[525,56,565,89])

add_block('built-in/Note',[sys,'/',['adaptive',13,'control/dq']])
set_param([sys,'/',['adaptive',13,'control/dq']],...
		'position',[300,5,305,10])

add_block('built-in/Note',[sys,'/',['adaptive',13,'control/dqq_r']])
set_param([sys,'/',['adaptive',13,'control/dqq_r']],...
		'position',[300,25,305,30])

add_block('built-in/Note',[sys,'/',['adaptive',13,'control/dq_r']])
set_param([sys,'/',['adaptive',13,'control/dq_r']],...
		'position',[300,45,305,50])

add_block('built-in/Note',[sys,'/',['adaptive',13,'control/sig']])
set_param([sys,'/',['adaptive',13,'control/sig']],...
		'position',[300,65,305,70])

add_block('built-in/Mux',[sys,'/',['adaptive',13,'control/Mux1']])
set_param([sys,'/',['adaptive',13,'control/Mux1']],...
		'hide name',0,...
		'position',[230,47,255,158])

add_block('built-in/Inport',[sys,'/',['adaptive',13,'control/in_1']])
set_param([sys,'/',['adaptive',13,'control/in_1']],...
		'hide name',0,...
		'position',[265,15,285,35])

add_block('built-in/Inport',[sys,'/',['adaptive',13,'control/in_3']])
set_param([sys,'/',['adaptive',13,'control/in_3']],...
		'hide name',0,...
		'Port','3',...
		'position',[265,55,285,75])

add_block('built-in/Inport',[sys,'/',['adaptive',13,'control/in_2']])
set_param([sys,'/',['adaptive',13,'control/in_2']],...
		'hide name',0,...
		'Port','2',...
		'position',[265,35,285,55])

add_block('built-in/Inport',[sys,'/',['adaptive',13,'control/in_4']])
set_param([sys,'/',['adaptive',13,'control/in_4']],...
		'hide name',0,...
		'Port','4',...
		'position',[265,75,285,95])

add_block('built-in/Outport',[sys,'/',['adaptive',13,'control/y1']])
set_param([sys,'/',['adaptive',13,'control/y1']],...
		'position',[585,55,605,75])
add_line([sys,'/',['adaptive',13,'control']],[290,85;320,85])
add_line([sys,'/',['adaptive',13,'control']],[260,105;320,105])
add_line([sys,'/',['adaptive',13,'control']],[215,140;225,140])
add_line([sys,'/',['adaptive',13,'control']],[215,115;225,115])
add_line([sys,'/',['adaptive',13,'control']],[215,90;225,90])
add_line([sys,'/',['adaptive',13,'control']],[215,65;225,65])
add_line([sys,'/',['adaptive',13,'control']],[290,65;320,65])
add_line([sys,'/',['adaptive',13,'control']],[290,45;320,45])
add_line([sys,'/',['adaptive',13,'control']],[500,75;520,75])
add_line([sys,'/',['adaptive',13,'control']],[570,65;580,65])
add_line([sys,'/',['adaptive',13,'control']],[475,160;440,160])
add_line([sys,'/',['adaptive',13,'control']],[570,80;580,80;580,160;540,160])
add_line([sys,'/',['adaptive',13,'control']],[290,25;320,25])
add_line([sys,'/',['adaptive',13,'control']],[390,160;360,160;360,200;430,200])
add_line([sys,'/',['adaptive',13,'control']],[355,75;360,75])
add_line([sys,'/',['adaptive',13,'control']],[420,75;430,75])
add_line([sys,'/',['adaptive',13,'control']],[30,65;35,65])
add_line([sys,'/',['adaptive',13,'control']],[95,65;125,65])
add_line([sys,'/',['adaptive',13,'control']],[360,160;305,160;305,125;320,125])
add_line([sys,'/',['adaptive',13,'control']],[105,65;105,90;125,90])
add_line([sys,'/',['adaptive',13,'control']],[105,90;105,115;125,115])
add_line([sys,'/',['adaptive',13,'control']],[105,115;105,140;125,140])
set_param([sys,'/',['adaptive',13,'control']],...
		'Mask Display','Y( . )pi_h')


%     Finished composite block ['adaptive',13,'control'].

set_param([sys,'/',['adaptive',13,'control']],...
		'move name',0,...
		'Font Name','Arial',...
		'position',[285,104,335,176])

add_block('built-in/Sum',[sys,'/','Sum6'])
set_param([sys,'/','Sum6'],...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[185,105,200,145])

add_block('built-in/Sum',[sys,'/','Sum7'])
set_param([sys,'/','Sum7'],...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[185,175,200,215])

add_block('built-in/From Workspace',[sys,'/',['From',13,'Workspace']])
set_param([sys,'/',['From',13,'Workspace']],...
		'hide name',0,...
		'Font Name','Arial',...
		'matl_expr','[T,q_d]',...
		'position',[5,183,55,207])

add_block('built-in/Sum',[sys,'/','Sum4'])
set_param([sys,'/','Sum4'],...
		'hide name',0,...
		'Font Name','Arial',...
		'inputs','+-',...
		'position',[85,185,100,225])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space5'])
set_param([sys,'/','Discrete State-Space5'],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','Lam',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','Lam')
set_param([sys,'/','Discrete State-Space5'],...
		'position',[120,189,150,221])


%     Subsystem  'Subsystem8'.

new_system([sys,'/','Subsystem8'])
set_param([sys,'/','Subsystem8'],'Location',[355,393414,500,393509])

add_block('built-in/Note',[sys,'/','Subsystem8/start'])
set_param([sys,'/','Subsystem8/start'],...
		'position',[55,45,60,50])
set_param([sys,'/','Subsystem8'],...
		'Mask Display','plot',...
		'Mask Dialogue','eval(''p6_14;'')')


%     Finished composite block 'Subsystem8'.

set_param([sys,'/','Subsystem8'],...
		'orientation',2,...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[515,290,585,321])

add_block('built-in/Sum',[sys,'/','Sum8'])
set_param([sys,'/','Sum8'],...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[360,130,375,170])


%     Subsystem  'arm'.

new_system([sys,'/','arm'])
set_param([sys,'/','arm'],'Location',[123,203,512,460])

add_block('built-in/Inport',[sys,'/','arm/tau'])
set_param([sys,'/','arm/tau'],...
		'position',[10,140,30,160])

add_block('built-in/Sum',[sys,'/','arm/Sum'])
set_param([sys,'/','arm/Sum'],...
		'hide name',0,...
		'inputs','--+-',...
		'position',[85,109,105,176])

add_block('built-in/Outport',[sys,'/','arm/dq'])
set_param([sys,'/','arm/dq'],...
		'position',[355,105,375,125])


%     Subsystem  'arm/resolved acc'.

new_system([sys,'/','arm/resolved acc'])
set_param([sys,'/','arm/resolved acc'],'Location',[142,197,432,294])

add_block('built-in/Inport',[sys,'/',['arm/resolved acc/tau-tau''']])
set_param([sys,'/',['arm/resolved acc/tau-tau''']],...
		'position',[10,20,30,40])

add_block('built-in/Inport',[sys,'/','arm/resolved acc/q'])
set_param([sys,'/','arm/resolved acc/q'],...
		'Port','2',...
		'position',[10,60,30,80])

add_block('built-in/Outport',[sys,'/','arm/resolved acc/ddq'])
set_param([sys,'/','arm/resolved acc/ddq'],...
		'position',[260,40,280,60])

add_block('built-in/Mux',[sys,'/','arm/resolved acc/Mux'])
set_param([sys,'/','arm/resolved acc/Mux'],...
		'hide name',0,...
		'inputs','[2,1]',...
		'position',[140,12,165,88])

add_block('built-in/Fcn',[sys,'/','arm/resolved acc/Fcn'])
set_param([sys,'/','arm/resolved acc/Fcn'],...
		'hide name',0,...
		'Expr','cos(u(2))',...
		'position',[50,59,105,81])

add_block('built-in/MATLAB Fcn',[sys,'/',['arm/resolved acc/invB',13,'']])
set_param([sys,'/',['arm/resolved acc/invB',13,'']],...
		'hide name',0,...
		'MATLAB Fcn','inv(iner_l(u(3)))*u(1:2)',...
		'Output Width','2',...
		'Mask Display','inv(B(q))',...
		'position',[185,33,235,67])
add_line([sys,'/','arm/resolved acc'],[170,50;180,50])
add_line([sys,'/','arm/resolved acc'],[35,30;135,30])
add_line([sys,'/','arm/resolved acc'],[240,50;255,50])
add_line([sys,'/','arm/resolved acc'],[35,70;45,70])
add_line([sys,'/','arm/resolved acc'],[110,70;135,70])
set_param([sys,'/','arm/resolved acc'],...
		'Mask Display','inv(B(q))')


%     Finished composite block 'arm/resolved acc'.

set_param([sys,'/','arm/resolved acc'],...
		'move name',0,...
		'position',[130,135,185,175])

add_block('built-in/Outport',[sys,'/',['arm/q',13,'']])
set_param([sys,'/',['arm/q',13,'']],...
		'Port','2',...
		'position',[355,145,375,165])

add_block('built-in/Integrator',[sys,'/','arm/Integrator1'])
set_param([sys,'/','arm/Integrator1'],...
		'hide name',0,...
		'Initial','q_i',...
		'position',[265,140,290,170])

add_block('built-in/Integrator',[sys,'/','arm/Integrator'])
set_param([sys,'/','arm/Integrator'],...
		'hide name',0,...
		'Initial','[0 0]',...
		'position',[205,140,230,170])

add_block('built-in/State-Space',[sys,'/','arm/friction'])
set_param([sys,'/','arm/friction'],...
		'orientation',2,...
		'move name',0,...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','F_v',...
		'Mask Type','Matrix Gain',...
		'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/','arm/friction'],...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','F_v\/',...
		'position',[140,79,175,111])


%     Subsystem  'arm/gravity'.

new_system([sys,'/','arm/gravity'])
set_param([sys,'/','arm/gravity'],'Location',[47,188,484,301])

add_block('built-in/Outport',[sys,'/','arm/gravity/g'])
set_param([sys,'/','arm/gravity/g'],...
		'orientation',2,...
		'position',[5,50,25,70])

add_block('built-in/Sum',[sys,'/','arm/gravity/Sum5'])
set_param([sys,'/','arm/gravity/Sum5'],...
		'orientation',2,...
		'hide name',0,...
		'position',[105,29,120,51])

add_block('built-in/Gain',[sys,'/','arm/gravity/Gain1'])
set_param([sys,'/','arm/gravity/Gain1'],...
		'orientation',2,...
		'hide name',0,...
		'Gain','g*pi_l(1)',...
		'Mask Display','k_1',...
		'position',[160,18,185,52])

add_block('built-in/Fcn',[sys,'/','arm/gravity/Fcn2'])
set_param([sys,'/','arm/gravity/Fcn2'],...
		'orientation',2,...
		'hide name',0,...
		'Expr','cos(u)',...
		'position',[210,25,250,45])

add_block('built-in/Gain',[sys,'/','arm/gravity/Gain'])
set_param([sys,'/','arm/gravity/Gain'],...
		'orientation',2,...
		'hide name',0,...
		'Gain','g*pi_l(3)',...
		'Mask Display','k_2',...
		'position',[160,63,185,97])

add_block('built-in/Demux',[sys,'/','arm/gravity/Demux'])
set_param([sys,'/','arm/gravity/Demux'],...
		'orientation',2,...
		'hide name',0,...
		'outputs','2',...
		'position',[340,12,380,108])

add_block('built-in/Sum',[sys,'/','arm/gravity/Sum2'])
set_param([sys,'/','arm/gravity/Sum2'],...
		'orientation',2,...
		'hide name',0,...
		'position',[270,70,290,90])

add_block('built-in/Fcn',[sys,'/','arm/gravity/Fcn1'])
set_param([sys,'/','arm/gravity/Fcn1'],...
		'orientation',2,...
		'hide name',0,...
		'Expr','cos(u)',...
		'position',[210,70,250,90])

add_block('built-in/Mux',[sys,'/','arm/gravity/Mux'])
set_param([sys,'/','arm/gravity/Mux'],...
		'orientation',2,...
		'hide name',0,...
		'inputs','2',...
		'position',[50,21,80,99])

add_block('built-in/Inport',[sys,'/','arm/gravity/q'])
set_param([sys,'/','arm/gravity/q'],...
		'orientation',2,...
		'position',[415,50,435,70])
add_line([sys,'/','arm/gravity'],[45,60;30,60])
add_line([sys,'/','arm/gravity'],[155,80;85,80])
add_line([sys,'/','arm/gravity'],[155,80;150,80;150,45;125,45])
add_line([sys,'/','arm/gravity'],[100,40;85,40])
add_line([sys,'/','arm/gravity'],[155,35;125,35])
add_line([sys,'/','arm/gravity'],[335,35;255,35])
add_line([sys,'/','arm/gravity'],[315,35;315,75;295,75])
add_line([sys,'/','arm/gravity'],[205,35;190,35])
add_line([sys,'/','arm/gravity'],[205,80;190,80])
add_line([sys,'/','arm/gravity'],[265,80;255,80])
add_line([sys,'/','arm/gravity'],[335,85;295,85])
add_line([sys,'/','arm/gravity'],[410,60;385,60])
set_param([sys,'/','arm/gravity'],...
		'Mask Display','g(q)')


%     Finished composite block 'arm/gravity'.

set_param([sys,'/','arm/gravity'],...
		'orientation',2,...
		'move name',0,...
		'position',[140,218,175,252])


%     Subsystem  'arm/Coriolis + centrifugal'.

new_system([sys,'/','arm/Coriolis + centrifugal'])
set_param([sys,'/','arm/Coriolis + centrifugal'],'Location',[36,268,587,438])

add_block('built-in/Demux',[sys,'/','arm/Coriolis + centrifugal/Demux2'])
set_param([sys,'/','arm/Coriolis + centrifugal/Demux2'],...
		'orientation',2,...
		'hide name',0,...
		'outputs','2',...
		'position',[440,74,480,136])

add_block('built-in/Product',[sys,'/','arm/Coriolis + centrifugal/Product4'])
set_param([sys,'/','arm/Coriolis + centrifugal/Product4'],...
		'orientation',2,...
		'hide name',0,...
		'position',[285,105,320,125])

add_block('built-in/Fcn',[sys,'/','arm/Coriolis + centrifugal/Fcn1'])
set_param([sys,'/','arm/Coriolis + centrifugal/Fcn1'],...
		'orientation',2,...
		'hide name',0,...
		'Expr','sin(u(2))',...
		'position',[430,39,480,61])

add_block('built-in/Gain',[sys,'/','arm/Coriolis + centrifugal/Gain'])
set_param([sys,'/','arm/Coriolis + centrifugal/Gain'],...
		'orientation',2,...
		'hide name',0,...
		'Gain','-a(1)*pi_l(3)',...
		'Mask Display','k_3',...
		'position',[380,38,405,62])

add_block('built-in/Outport',[sys,'/','arm/Coriolis + centrifugal/Cdq'])
set_param([sys,'/','arm/Coriolis + centrifugal/Cdq'],...
		'orientation',2,...
		'position',[5,100,25,120])

add_block('built-in/Gain',[sys,'/','arm/Coriolis + centrifugal/Gain2'])
set_param([sys,'/','arm/Coriolis + centrifugal/Gain2'],...
		'orientation',2,...
		'hide name',0,...
		'Gain','-1',...
		'position',[150,23,175,47])

add_block('built-in/Gain',[sys,'/','arm/Coriolis + centrifugal/Gain1'])
set_param([sys,'/','arm/Coriolis + centrifugal/Gain1'],...
		'orientation',2,...
		'hide name',0,...
		'Gain','2',...
		'position',[150,83,175,107])

add_block('built-in/Product',[sys,'/','arm/Coriolis + centrifugal/Product6'])
set_param([sys,'/','arm/Coriolis + centrifugal/Product6'],...
		'orientation',2,...
		'hide name',0,...
		'position',[195,25,230,45])

add_block('built-in/Product',[sys,'/','arm/Coriolis + centrifugal/prdiuct 1'])
set_param([sys,'/','arm/Coriolis + centrifugal/prdiuct 1'],...
		'orientation',2,...
		'hide name',0,...
		'move name',0,...
		'position',[285,20,320,40])

add_block('built-in/Product',[sys,'/','arm/Coriolis + centrifugal/Product5'])
set_param([sys,'/','arm/Coriolis + centrifugal/Product5'],...
		'orientation',2,...
		'hide name',0,...
		'position',[195,130,230,150])

add_block('built-in/Product',[sys,'/','arm/Coriolis + centrifugal/Product7'])
set_param([sys,'/','arm/Coriolis + centrifugal/Product7'],...
		'orientation',2,...
		'hide name',0,...
		'position',[195,85,230,105])

add_block('built-in/Sum',[sys,'/','arm/Coriolis + centrifugal/Sum'])
set_param([sys,'/','arm/Coriolis + centrifugal/Sum'],...
		'orientation',2,...
		'hide name',0,...
		'position',[105,90,125,110])

add_block('built-in/Mux',[sys,'/','arm/Coriolis + centrifugal/Mux'])
set_param([sys,'/','arm/Coriolis + centrifugal/Mux'],...
		'orientation',2,...
		'hide name',0,...
		'inputs','2',...
		'position',[40,92,70,123])

add_block('built-in/Inport',[sys,'/','arm/Coriolis + centrifugal/q'])
set_param([sys,'/','arm/Coriolis + centrifugal/q'],...
		'orientation',2,...
		'position',[525,40,545,60])

add_block('built-in/Inport',[sys,'/','arm/Coriolis + centrifugal/dq'])
set_param([sys,'/','arm/Coriolis + centrifugal/dq'],...
		'orientation',2,...
		'Port','2',...
		'position',[525,95,545,115])
add_line([sys,'/','arm/Coriolis + centrifugal'],[280,115;270,115;270,135;235,135])
add_line([sys,'/','arm/Coriolis + centrifugal'],[270,115;270,100;235,100])
add_line([sys,'/','arm/Coriolis + centrifugal'],[435,90;335,90;325,35])
add_line([sys,'/','arm/Coriolis + centrifugal'],[335,90;270,90;270,40;235,40])
add_line([sys,'/','arm/Coriolis + centrifugal'],[270,90;235,90])
add_line([sys,'/','arm/Coriolis + centrifugal'],[520,50;485,50])
add_line([sys,'/','arm/Coriolis + centrifugal'],[425,50;410,50])
add_line([sys,'/','arm/Coriolis + centrifugal'],[375,50;355,50;355,25;325,25])
add_line([sys,'/','arm/Coriolis + centrifugal'],[355,50;355,110;325,110])
add_line([sys,'/','arm/Coriolis + centrifugal'],[280,30;235,30])
add_line([sys,'/','arm/Coriolis + centrifugal'],[435,120;325,120])
add_line([sys,'/','arm/Coriolis + centrifugal'],[355,120;355,145;235,145])
add_line([sys,'/','arm/Coriolis + centrifugal'],[190,95;180,95])
add_line([sys,'/','arm/Coriolis + centrifugal'],[145,95;130,95])
add_line([sys,'/','arm/Coriolis + centrifugal'],[190,140;150,140;150,105;130,105])
add_line([sys,'/','arm/Coriolis + centrifugal'],[100,100;75,100])
add_line([sys,'/','arm/Coriolis + centrifugal'],[35,110;30,110])
add_line([sys,'/','arm/Coriolis + centrifugal'],[190,35;180,35])
add_line([sys,'/','arm/Coriolis + centrifugal'],[145,35;95,35;95,115;75,115])
add_line([sys,'/','arm/Coriolis + centrifugal'],[520,105;485,105])
set_param([sys,'/','arm/Coriolis + centrifugal'],...
		'Mask Display','C(q,dq)dq')


%     Finished composite block 'arm/Coriolis + centrifugal'.

set_param([sys,'/','arm/Coriolis + centrifugal'],...
		'orientation',2,...
		'move name',0,...
		'position',[130,20,185,55])
add_line([sys,'/','arm'],[295,155;310,155;310,200;115,200;125,165])
add_line([sys,'/','arm'],[310,155;350,155])
add_line([sys,'/','arm'],[235,155;243,155;243,95;180,95])
add_line([sys,'/','arm'],[243,95;243,45;190,45])
add_line([sys,'/','arm'],[243,115;350,115])
add_line([sys,'/','arm'],[135,235;65,235;65,165;80,165])
add_line([sys,'/','arm'],[135,95;65,95;65,120;80,120])
add_line([sys,'/','arm'],[310,200;310,235;180,235])
add_line([sys,'/','arm'],[110,145;125,145])
add_line([sys,'/','arm'],[235,155;260,155])
add_line([sys,'/','arm'],[190,155;200,155])
add_line([sys,'/','arm'],[35,150;80,150])
add_line([sys,'/','arm'],[310,155;310,30;190,30])
add_line([sys,'/','arm'],[125,40;50,40;50,135;80,135])
set_param([sys,'/','arm'],...
		'Mask Display','inv(B(q))(tau-tau'')')


%     Finished composite block 'arm'.

set_param([sys,'/','arm'],...
		'move name',0,...
		'Font Name','Arial',...
		'position',[390,131,485,169])

add_block('built-in/To Workspace',[sys,'/','To Workspace6'])
set_param([sys,'/','To Workspace6'],...
		'hide name',0,...
		'Font Name','Arial',...
		'mat-name','q',...
		'buffer','[5001,1,Ts]',...
		'position',[535,150,585,170])

add_block('built-in/To Workspace',[sys,'/','To Workspace4'])
set_param([sys,'/','To Workspace4'],...
		'hide name',0,...
		'Font Name','Arial',...
		'mat-name','time',...
		'buffer','[5001,1,Ts]',...
		'position',[535,5,585,25])

add_block('built-in/Clock',[sys,'/','Clock'])
set_param([sys,'/','Clock'],...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[485,5,505,25])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space6'])
set_param([sys,'/','Discrete State-Space6'],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','K_d',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','K_d')
set_param([sys,'/','Discrete State-Space6'],...
		'position',[295,189,325,221])

add_block('built-in/Note',[sys,'/','dq'])
set_param([sys,'/','dq'],...
		'Font Name','Arial',...
		'position',[490,120,495,125])
add_line(sys,[510,15;530,15])
add_line(sys,[105,135;115,135])
add_line(sys,[105,205;115,205])
add_line(sys,[490,160;530,160])
add_line(sys,[60,145;80,145])
add_line(sys,[60,195;80,195])
add_line(sys,[105,205;105,245;130,245])
add_line(sys,[155,205;180,205])
add_line(sys,[205,195;225,195])
add_line(sys,[205,125;280,125])
add_line(sys,[250,205;255,205;255,155;280,155])
add_line(sys,[380,150;385,150])
add_line(sys,[340,140;355,140])
add_line(sys,[250,205;290,205])
add_line(sys,[330,205;345,205;355,160])
add_line(sys,[155,135;180,135])
add_line(sys,[60,95;165,95;165,115;180,115])
add_line(sys,[70,145;70,165;165,165;165,185;180,185])
add_line(sys,[205,195;205,140;280,140])
add_line(sys,[490,140;500,140;500,70;270,70;280,110])
add_line(sys,[270,70;70,70;80,125])
add_line(sys,[515,160;515,270;70,270;80,215])
add_line(sys,[270,270;280,170])
add_line(sys,[500,140;500,245;205,245;205,215;225,215])

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
