function [ret,x0,str,ts,xts]=s6_15(t,x,u,flag);
%S6_15	is the M-file description of the SIMULINK system named S6_15.
%	The block-diagram can be displayed by typing: S6_15.
%
%	SYS=S6_15(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_15 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_15 with a FLAG of zero:
%	[SIZES]=S6_15([],[],[],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',[36,93,573,417])
     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  'Subsystem3'.

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

add_block('built-in/Note',[sys,'/','Subsystem3/start'])
set_param([sys,'/','Subsystem3/start'],...
		'position',[55,45,60,50])
set_param([sys,'/','Subsystem3'],...
		'Mask Display','p_d=[0.6 -0.2]',...
		'Mask Dialogue','eval(''clear all;c=1;i6_15;'')')


%     Finished composite block 'Subsystem3'.

set_param([sys,'/','Subsystem3'],...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[95,5,175,31])


%     Subsystem  'Subsystem2'.

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

add_block('built-in/Note',[sys,'/','Subsystem2/start'])
set_param([sys,'/','Subsystem2/start'],...
		'position',[55,45,60,50])
set_param([sys,'/','Subsystem2'],...
		'Mask Display','p_d=[0.5 0.5]',...
		'Mask Dialogue','eval(''clear all;c=0;i6_15;'')')


%     Finished composite block 'Subsystem2'.

set_param([sys,'/','Subsystem2'],...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[5,5,85,31])


%     Subsystem  ['gravity',13,'compensation'].

new_system([sys,'/',['gravity',13,'compensation']])
set_param([sys,'/',['gravity',13,'compensation']],'Location',[72,102,564,215])

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

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

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

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

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

add_block('built-in/Discrete State-Space',[sys,'/',['gravity',13,'compensation/Discrete State-Space2']])
set_param([sys,'/',['gravity',13,'compensation/Discrete State-Space2']],...
		'orientation',2,...
		'hide name',0,...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','eye(2,2)',...
		'X0','0',...
		'Sample time','Tc')
set_param([sys,'/',['gravity',13,'compensation/Discrete State-Space2']],...
		'Mask Display','Sampler',...
		'position',[400,44,450,76])

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

add_block('built-in/Sum',[sys,'/',['gravity',13,'compensation/Sum2']])
set_param([sys,'/',['gravity',13,'compensation/Sum2']],...
		'orientation',2,...
		'hide name',0,...
		'position',[275,69,290,91])

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

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

add_block('built-in/Inport',[sys,'/',['gravity',13,'compensation/q']])
set_param([sys,'/',['gravity',13,'compensation/q']],...
		'orientation',2,...
		'position',[465,50,485,70])
add_line([sys,'/',['gravity',13,'compensation']],[45,60;30,60])
add_line([sys,'/',['gravity',13,'compensation']],[155,80;150,80;150,45;125,45])
add_line([sys,'/',['gravity',13,'compensation']],[155,80;85,80])
add_line([sys,'/',['gravity',13,'compensation']],[100,40;85,40])
add_line([sys,'/',['gravity',13,'compensation']],[155,35;125,35])
add_line([sys,'/',['gravity',13,'compensation']],[335,35;255,35])
add_line([sys,'/',['gravity',13,'compensation']],[315,35;315,75;295,75])
add_line([sys,'/',['gravity',13,'compensation']],[205,35;190,35])
add_line([sys,'/',['gravity',13,'compensation']],[205,80;190,80])
add_line([sys,'/',['gravity',13,'compensation']],[270,80;255,80])
add_line([sys,'/',['gravity',13,'compensation']],[335,85;295,85])
add_line([sys,'/',['gravity',13,'compensation']],[395,60;385,60])
add_line([sys,'/',['gravity',13,'compensation']],[460,60;455,60])
set_param([sys,'/',['gravity',13,'compensation']],...
		'Mask Display','g(q)')


%     Finished composite block ['gravity',13,'compensation'].

set_param([sys,'/',['gravity',13,'compensation']],...
		'orientation',2,...
		'move name',0,...
		'Font Name','Arial',...
		'position',[365,202,395,238])

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

add_block('built-in/Constant',[sys,'/','Constant'])
set_param([sys,'/','Constant'],...
		'hide name',0,...
		'Font Name','Arial',...
		'Value','p_d',...
		'position',[5,153,30,177])

add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
		'hide name',0,...
		'Font Name','Arial',...
		'inputs','-+',...
		'position',[170,108,190,152])


%     Subsystem  'Subsystem4'.

new_system([sys,'/','Subsystem4'])
set_param([sys,'/','Subsystem4'],'Location',[254,220,549,344])

add_block('built-in/Inport',[sys,'/','Subsystem4/cs'])
set_param([sys,'/','Subsystem4/cs'],...
		'Port','2',...
		'position',[5,80,25,100])

add_block('built-in/Inport',[sys,'/','Subsystem4/dq'])
set_param([sys,'/','Subsystem4/dq'],...
		'position',[5,45,25,65])

add_block('built-in/Discrete State-Space',[sys,'/','Subsystem4/Discrete State-Space2'])
set_param([sys,'/','Subsystem4/Discrete State-Space2'],...
		'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,'/','Subsystem4/Discrete State-Space2'],...
		'position',[45,40,95,70])

add_block('built-in/Mux',[sys,'/','Subsystem4/Mux'])
set_param([sys,'/','Subsystem4/Mux'],...
		'hide name',0,...
		'inputs','[2,4]',...
		'position',[120,39,145,106])

add_block('built-in/MATLAB Fcn',[sys,'/','Subsystem4/MATLAB Fcn'])
set_param([sys,'/','Subsystem4/MATLAB Fcn'],...
		'hide name',0,...
		'MATLAB Fcn','J_adq',...
		'Output Width','2',...
		'Mask Display','J_a(q)dq',...
		'position',[170,58,230,92])

add_block('built-in/Outport',[sys,'/','Subsystem4/dx'])
set_param([sys,'/','Subsystem4/dx'],...
		'position',[255,65,275,85])
add_line([sys,'/','Subsystem4'],[100,55;115,55])
add_line([sys,'/','Subsystem4'],[30,55;40,55])
add_line([sys,'/','Subsystem4'],[30,90;115,90])
add_line([sys,'/','Subsystem4'],[150,75;165,75])
add_line([sys,'/','Subsystem4'],[235,75;250,75])
set_param([sys,'/','Subsystem4'],...
		'Mask Display','J_a(q)')


%     Finished composite block 'Subsystem4'.

set_param([sys,'/','Subsystem4'],...
		'orientation',2,...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[135,55,185,90])


%     Subsystem  ['sinusoidal',13,' functions'].

new_system([sys,'/',['sinusoidal',13,' functions']])
set_param([sys,'/',['sinusoidal',13,' functions']],'Location',[56,166,511,288])

add_block('built-in/Inport',[sys,'/',['sinusoidal',13,' functions/q']])
set_param([sys,'/',['sinusoidal',13,' functions/q']],...
		'position',[5,85,25,105])

add_block('built-in/Note',[sys,'/',['sinusoidal',13,' functions/q1 + q2']])
set_param([sys,'/',['sinusoidal',13,' functions/q1 + q2']],...
		'position',[220,70,225,75])

add_block('built-in/Demux',[sys,'/',['sinusoidal',13,' functions/Demux']])
set_param([sys,'/',['sinusoidal',13,' functions/Demux']],...
		'hide name',0,...
		'outputs','2',...
		'position',[120,77,160,113])

add_block('built-in/Sum',[sys,'/',['sinusoidal',13,' functions/Sum2']])
set_param([sys,'/',['sinusoidal',13,' functions/Sum2']],...
		'hide name',0,...
		'position',[185,75,200,115])

add_block('built-in/Outport',[sys,'/',['sinusoidal',13,' functions/cs']])
set_param([sys,'/',['sinusoidal',13,' functions/cs']],...
		'position',[430,50,450,70])

add_block('built-in/Mux',[sys,'/',['sinusoidal',13,' functions/Mux']])
set_param([sys,'/',['sinusoidal',13,' functions/Mux']],...
		'hide name',0,...
		'position',[380,4,405,111])

add_block('built-in/Fcn',[sys,'/',['sinusoidal',13,' functions/Fcn3']])
set_param([sys,'/',['sinusoidal',13,' functions/Fcn3']],...
		'hide name',0,...
		'Expr','a(1)*sin(u)',...
		'Mask Display','',...
		'position',[285,59,355,81])

add_block('built-in/Fcn',[sys,'/',['sinusoidal',13,' functions/Fcn1']])
set_param([sys,'/',['sinusoidal',13,' functions/Fcn1']],...
		'hide name',0,...
		'Expr','a(2)*cos(u)',...
		'position',[285,34,355,56])

add_block('built-in/Fcn',[sys,'/',['sinusoidal',13,' functions/Fcn']])
set_param([sys,'/',['sinusoidal',13,' functions/Fcn']],...
		'hide name',0,...
		'Expr','a(1)*cos(u)',...
		'Mask Display','',...
		'position',[285,9,355,31])

add_block('built-in/Fcn',[sys,'/',['sinusoidal',13,' functions/Fcn4']])
set_param([sys,'/',['sinusoidal',13,' functions/Fcn4']],...
		'hide name',0,...
		'Expr','a(2)*sin(u)',...
		'Mask Display','',...
		'position',[285,84,355,106])

add_block('built-in/Discrete State-Space',[sys,'/',['sinusoidal',13,' functions/Discrete State-Space2']])
set_param([sys,'/',['sinusoidal',13,' functions/Discrete State-Space2']],...
		'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,'/',['sinusoidal',13,' functions/Discrete State-Space2']],...
		'position',[50,80,100,110])
add_line([sys,'/',['sinusoidal',13,' functions']],[360,20;375,20])
add_line([sys,'/',['sinusoidal',13,' functions']],[410,60;425,60])
add_line([sys,'/',['sinusoidal',13,' functions']],[165,85;180,85])
add_line([sys,'/',['sinusoidal',13,' functions']],[165,105;180,105])
add_line([sys,'/',['sinusoidal',13,' functions']],[205,95;250,95;250,45;280,45])
add_line([sys,'/',['sinusoidal',13,' functions']],[250,95;280,95])
add_line([sys,'/',['sinusoidal',13,' functions']],[165,85;165,20;280,20])
add_line([sys,'/',['sinusoidal',13,' functions']],[360,45;375,45])
add_line([sys,'/',['sinusoidal',13,' functions']],[360,70;375,70])
add_line([sys,'/',['sinusoidal',13,' functions']],[360,95;375,95])
add_line([sys,'/',['sinusoidal',13,' functions']],[165,70;280,70])
add_line([sys,'/',['sinusoidal',13,' functions']],[30,95;45,95])
add_line([sys,'/',['sinusoidal',13,' functions']],[105,95;115,95])
set_param([sys,'/',['sinusoidal',13,' functions']],...
		'Mask Display','cs(q)')


%     Finished composite block ['sinusoidal',13,' functions'].

set_param([sys,'/',['sinusoidal',13,' functions']],...
		'orientation',2,...
		'move name',0,...
		'Font Name','Arial',...
		'position',[225,248,255,282])


%     Subsystem  ['Jacobian',13,'transpose'].

new_system([sys,'/',['Jacobian',13,'transpose']])
set_param([sys,'/',['Jacobian',13,'transpose']],'Location',[318,316,535,399])

add_block('built-in/Mux',[sys,'/',['Jacobian',13,'transpose/Mux']])
set_param([sys,'/',['Jacobian',13,'transpose/Mux']],...
		'hide name',0,...
		'inputs','[2,4]',...
		'position',[55,9,80,76])

add_block('built-in/Inport',[sys,'/',['Jacobian',13,'transpose/cs']])
set_param([sys,'/',['Jacobian',13,'transpose/cs']],...
		'Port','2',...
		'position',[5,50,25,70])

add_block('built-in/Inport',[sys,'/',['Jacobian',13,'transpose/y']])
set_param([sys,'/',['Jacobian',13,'transpose/y']],...
		'position',[5,15,25,35])

add_block('built-in/Outport',[sys,'/',['Jacobian',13,'transpose/y1']])
set_param([sys,'/',['Jacobian',13,'transpose/y1']],...
		'position',[190,35,210,55])

add_block('built-in/MATLAB Fcn',[sys,'/',['Jacobian',13,'transpose/MATLAB Fcn']])
set_param([sys,'/',['Jacobian',13,'transpose/MATLAB Fcn']],...
		'hide name',0,...
		'MATLAB Fcn','trJ_a',...
		'Output Width','2',...
		'Mask Display','J''_a(q)y',...
		'position',[110,29,165,61])
add_line([sys,'/',['Jacobian',13,'transpose']],[170,45;185,45])
add_line([sys,'/',['Jacobian',13,'transpose']],[85,45;105,45])
add_line([sys,'/',['Jacobian',13,'transpose']],[30,60;50,60])
add_line([sys,'/',['Jacobian',13,'transpose']],[30,25;50,25])
set_param([sys,'/',['Jacobian',13,'transpose']],...
		'Mask Display','tr(J_a(q))')


%     Finished composite block ['Jacobian',13,'transpose'].

set_param([sys,'/',['Jacobian',13,'transpose']],...
		'move name',0,...
		'Font Name','Arial',...
		'position',[220,120,270,160])

add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[295,128,315,172])

add_block('built-in/Note',[sys,'/','dq'])
set_param([sys,'/','dq'],...
		'Font Name','Arial',...
		'position',[440,120,445,125])


%     Subsystem  'arm'.

new_system([sys,'/','arm'])
set_param([sys,'/','arm'],'Location',[4,112,393,369])


%     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/Inport',[sys,'/','arm/Coriolis + centrifugal/dq'])
set_param([sys,'/','arm/Coriolis + centrifugal/dq'],...
		'orientation',2,...
		'Port','2',...
		'position',[525,95,545,115])

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/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/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/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/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/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/Product6'])
set_param([sys,'/','arm/Coriolis + centrifugal/Product6'],...
		'orientation',2,...
		'hide name',0,...
		'position',[195,25,230,45])

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/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/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/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/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/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/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_line([sys,'/','arm/Coriolis + centrifugal'],[520,105;485,105])
add_line([sys,'/','arm/Coriolis + centrifugal'],[145,35;95,35;95,115;75,115])
add_line([sys,'/','arm/Coriolis + centrifugal'],[190,35;180,35])
add_line([sys,'/','arm/Coriolis + centrifugal'],[35,110;30,110])
add_line([sys,'/','arm/Coriolis + centrifugal'],[100,100;75,100])
add_line([sys,'/','arm/Coriolis + centrifugal'],[190,140;150,140;150,105;130,105])
add_line([sys,'/','arm/Coriolis + centrifugal'],[145,95;130,95])
add_line([sys,'/','arm/Coriolis + centrifugal'],[190,95;180,95])
add_line([sys,'/','arm/Coriolis + centrifugal'],[280,115;270,115;270,135;235,135])
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'],[435,120;325,120])
add_line([sys,'/','arm/Coriolis + centrifugal'],[355,120;355,145;235,145])
add_line([sys,'/','arm/Coriolis + centrifugal'],[280,30;235,30])
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'],[425,50;410,50])
add_line([sys,'/','arm/Coriolis + centrifugal'],[520,50;485,50])
add_line([sys,'/','arm/Coriolis + centrifugal'],[270,90;235,90])
add_line([sys,'/','arm/Coriolis + centrifugal'],[270,115;270,100;235,100])
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])


%     Subsystem  'arm/gravity'.

new_system([sys,'/','arm/gravity'])
set_param([sys,'/','arm/gravity'],'Location',[45,250,482,363])

add_block('built-in/Inport',[sys,'/','arm/gravity/q'])
set_param([sys,'/','arm/gravity/q'],...
		'orientation',2,...
		'position',[415,50,435,70])

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/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/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/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/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/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/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/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/Outport',[sys,'/','arm/gravity/g'])
set_param([sys,'/','arm/gravity/g'],...
		'orientation',2,...
		'position',[5,50,25,70])
add_line([sys,'/','arm/gravity'],[410,60;385,60])
add_line([sys,'/','arm/gravity'],[335,85;295,85])
add_line([sys,'/','arm/gravity'],[265,80;255,80])
add_line([sys,'/','arm/gravity'],[205,80;190,80])
add_line([sys,'/','arm/gravity'],[205,35;190,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'],[155,35;125,35])
add_line([sys,'/','arm/gravity'],[100,40;85,40])
add_line([sys,'/','arm/gravity'],[155,80;150,80;150,45;125,45])
add_line([sys,'/','arm/gravity'],[155,80;85,80])
add_line([sys,'/','arm/gravity'],[45,60;30,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])

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])

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/Integrator',[sys,'/','arm/Integrator1'])
set_param([sys,'/','arm/Integrator1'],...
		'hide name',0,...
		'Initial','q_i',...
		'position',[265,140,290,170])

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


%     Subsystem  'arm/resolved acc'.

new_system([sys,'/','arm/resolved acc'])
set_param([sys,'/','arm/resolved acc'],'Location',[198,201,488,298])

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/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/Outport',[sys,'/','arm/resolved acc/ddq'])
set_param([sys,'/','arm/resolved acc/ddq'],...
		'position',[260,40,280,60])

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/Inport',[sys,'/',['arm/resolved acc/tau-tau''']])
set_param([sys,'/',['arm/resolved acc/tau-tau''']],...
		'position',[10,20,30,40])

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'],[110,70;135,70])
add_line([sys,'/','arm/resolved acc'],[35,70;45,70])
add_line([sys,'/','arm/resolved acc'],[240,50;255,50])
add_line([sys,'/','arm/resolved acc'],[35,30;135,30])
add_line([sys,'/','arm/resolved acc'],[170,50;180,50])
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/dq'])
set_param([sys,'/','arm/dq'],...
		'position',[355,105,375,125])

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/Inport',[sys,'/','arm/tau'])
set_param([sys,'/','arm/tau'],...
		'position',[10,140,30,160])
add_line([sys,'/','arm'],[125,40;50,40;50,135;80,135])
add_line([sys,'/','arm'],[35,150;80,150])
add_line([sys,'/','arm'],[295,155;310,155;310,200;115,200;125,165])
add_line([sys,'/','arm'],[310,155;310,30;190,30])
add_line([sys,'/','arm'],[235,155;243,155;243,95;180,95])
add_line([sys,'/','arm'],[190,155;200,155])
add_line([sys,'/','arm'],[235,155;260,155])
add_line([sys,'/','arm'],[110,145;125,145])
add_line([sys,'/','arm'],[310,200;310,235;180,235])
add_line([sys,'/','arm'],[135,95;65,95;65,120;80,120])
add_line([sys,'/','arm'],[135,235;65,235;65,165;80,165])
add_line([sys,'/','arm'],[243,115;350,115])
add_line([sys,'/','arm'],[243,95;243,45;190,45])
add_line([sys,'/','arm'],[310,155;350,155])
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',[335,131,430,169])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space3'])
set_param([sys,'/','Discrete State-Space3'],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','K_p',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','K_p')
set_param([sys,'/','Discrete State-Space3'],...
		'position',[100,160,130,190])

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','K_d',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','K_d')
set_param([sys,'/','Discrete State-Space5'],...
		'position',[100,104,130,136])


%     Subsystem  ['direct ',13,'kinematics'].

new_system([sys,'/',['direct ',13,'kinematics']])
set_param([sys,'/',['direct ',13,'kinematics']],'Location',[42,225,356,290])

add_block('built-in/Inport',[sys,'/',['direct ',13,'kinematics/cs']])
set_param([sys,'/',['direct ',13,'kinematics/cs']],...
		'position',[10,30,30,50])

add_block('built-in/Sum',[sys,'/',['direct ',13,'kinematics/Sum1']])
set_param([sys,'/',['direct ',13,'kinematics/Sum1']],...
		'hide name',0,...
		'inputs','+',...
		'position',[130,34,150,56])

add_block('built-in/Demux',[sys,'/',['direct ',13,'kinematics/Demux']])
set_param([sys,'/',['direct ',13,'kinematics/Demux']],...
		'hide name',0,...
		'outputs','[2,2]',...
		'position',[55,21,105,54])

add_block('built-in/Note',[sys,'/',['direct ',13,'kinematics/y']])
set_param([sys,'/',['direct ',13,'kinematics/y']],...
		'position',[205,25,210,30])

add_block('built-in/Note',[sys,'/',['direct ',13,'kinematics/x']])
set_param([sys,'/',['direct ',13,'kinematics/x']],...
		'position',[205,10,210,15])

add_block('built-in/Sum',[sys,'/',['direct ',13,'kinematics/Sum']])
set_param([sys,'/',['direct ',13,'kinematics/Sum']],...
		'hide name',0,...
		'inputs','+',...
		'position',[170,19,190,41])

add_block('built-in/Mux',[sys,'/',['direct ',13,'kinematics/Mux']])
set_param([sys,'/',['direct ',13,'kinematics/Mux']],...
		'hide name',0,...
		'inputs','2',...
		'position',[225,23,255,52])

add_block('built-in/Outport',[sys,'/',['direct ',13,'kinematics/p']])
set_param([sys,'/',['direct ',13,'kinematics/p']],...
		'position',[280,30,300,50])
add_line([sys,'/',['direct ',13,'kinematics']],[155,45;220,45])
add_line([sys,'/',['direct ',13,'kinematics']],[195,30;220,30])
add_line([sys,'/',['direct ',13,'kinematics']],[110,45;125,45])
add_line([sys,'/',['direct ',13,'kinematics']],[110,30;165,30])
add_line([sys,'/',['direct ',13,'kinematics']],[35,40;50,40])
add_line([sys,'/',['direct ',13,'kinematics']],[260,40;275,40])
set_param([sys,'/',['direct ',13,'kinematics']],...
		'Mask Display','k(q)')


%     Finished composite block ['direct ',13,'kinematics'].

set_param([sys,'/',['direct ',13,'kinematics']],...
		'orientation',2,...
		'move name',0,...
		'Font Name','Arial',...
		'position',[140,248,170,282])

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

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


%     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_15;'')')


%     Finished composite block 'Subsystem8'.

set_param([sys,'/','Subsystem8'],...
		'orientation',2,...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[460,285,530,316])

add_block('built-in/To Workspace',[sys,'/','To Workspace6'])
set_param([sys,'/','To Workspace6'],...
		'hide name',0,...
		'Font Name','Arial',...
		'mat-name','p',...
		'buffer','[4001,1,Ts]',...
		'position',[75,210,125,230])

add_block('built-in/Note',[sys,'/','q'])
set_param([sys,'/','q'],...
		'Font Name','Arial',...
		'position',[440,140,445,145])
add_line(sys,[320,150;330,150])
add_line(sys,[80,175;95,175])
add_line(sys,[445,15;475,15])
add_line(sys,[35,165;55,165])
add_line(sys,[435,160;450,160;450,220;400,220])
add_line(sys,[360,220;275,220;275,160;290,160])
add_line(sys,[275,140;290,140])
add_line(sys,[450,220;450,265;260,265])
add_line(sys,[220,265;200,265;190,80])
add_line(sys,[200,150;215,150])
add_line(sys,[195,130;215,130])
add_line(sys,[135,120;165,120])
add_line(sys,[130,75;70,75;70,120;95,120])
add_line(sys,[135,175;145,175;145,140;165,140])
add_line(sys,[435,140;450,140;450,65;190,65])
add_line(sys,[200,265;175,265])
add_line(sys,[135,265;40,265;40,185;55,185])
add_line(sys,[40,220;70,220])

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
