function [ret,x0,str,ts,xts]=s6_11(t,x,u,flag);
%S6_11	is the M-file description of the SIMULINK system named S6_11.
%	The block-diagram can be displayed by typing: S6_11.
%
%	SYS=S6_11(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_11 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_11 with a FLAG of zero:
%	[SIZES]=S6_11([],[],[],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',[6,49,553,421])
     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  'Subsystem4'.

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

add_block('built-in/Note',[sys,'/','Subsystem4/start'])
set_param([sys,'/','Subsystem4/start'],...
		'position',[55,45,60,50])
set_param([sys,'/','Subsystem4'],...
		'Mask Display','K_p = 5\nK_v = 10',...
		'Mask Dialogue','eval(''clear all;c=0;i6_11;'')')


%     Finished composite block 'Subsystem4'.

set_param([sys,'/','Subsystem4'],...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[5,5,75,46])


%     Subsystem  'Subsystem5'.

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

add_block('built-in/Note',[sys,'/','Subsystem5/start'])
set_param([sys,'/','Subsystem5/start'],...
		'position',[55,45,60,50])
set_param([sys,'/','Subsystem5'],...
		'Mask Display','K_p = 6.25\nK_v = 32',...
		'Mask Dialogue','eval(''clear all;c=1;i6_11;'')')


%     Finished composite block 'Subsystem5'.

set_param([sys,'/','Subsystem5'],...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[90,5,160,46])

add_block('built-in/Sum',[sys,'/','Sum4'])
set_param([sys,'/','Sum4'],...
		'hide name',0,...
		'Font Name','Arial',...
		'position',[375,204,395,231])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space4'])
set_param([sys,'/','Discrete State-Space4'],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','Ad',...
		'B','Bd',...
		'C','Cd',...
		'D','Dd',...
		'X0','[0 0]',...
		'Sample time','Tc',...
		'Mask Display','PI')
set_param([sys,'/','Discrete State-Space4'],...
		'position',[320,208,355,242])


%     Subsystem  ['voltage-controlled',13,'arm'].

new_system([sys,'/',['voltage-controlled',13,'arm']])
set_param([sys,'/',['voltage-controlled',13,'arm']],'Location',[30,129,366,317])

add_block('built-in/Outport',[sys,'/',['voltage-controlled',13,'arm/q']])
set_param([sys,'/',['voltage-controlled',13,'arm/q']],...
		'position',[300,100,320,120])

add_block('built-in/Outport',[sys,'/',['voltage-controlled',13,'arm/dq']])
set_param([sys,'/',['voltage-controlled',13,'arm/dq']],...
		'Port','2',...
		'position',[300,145,320,165])


%     Subsystem  ['voltage-controlled',13,'arm/arm'].

new_system([sys,'/',['voltage-controlled',13,'arm/arm']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm']],'Location',[231,203,620,460])


%     Subsystem  ['voltage-controlled',13,'arm/arm/Coriolis + centrifugal'].

new_system([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],'Location',[33,290,584,460])

add_block('built-in/Inport',[sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/dq']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/dq']],...
		'orientation',2,...
		'Port','2',...
		'position',[525,95,545,115])

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

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

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

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

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

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

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

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

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

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

add_block('built-in/Gain',[sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/Gain']])
set_param([sys,'/',['voltage-controlled',13,'arm/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,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/Fcn1']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/Fcn1']],...
		'orientation',2,...
		'hide name',0,...
		'Expr','sin(u(2))',...
		'position',[430,39,480,61])

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

add_block('built-in/Demux',[sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/Demux2']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal/Demux2']],...
		'orientation',2,...
		'hide name',0,...
		'outputs','2',...
		'position',[440,74,480,136])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[520,105;485,105])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[145,35;95,35;95,115;75,115])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[190,35;180,35])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[35,110;30,110])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[100,100;75,100])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[190,140;150,140;150,105;130,105])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[145,95;130,95])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[190,95;180,95])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[280,115;270,115;270,135;235,135])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[435,90;335,90;325,35])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[335,90;270,90;270,40;235,40])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[435,120;325,120])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[355,120;355,145;235,145])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[280,30;235,30])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[375,50;355,50;355,25;325,25])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[355,50;355,110;325,110])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[425,50;410,50])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[520,50;485,50])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[270,90;235,90])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],[270,115;270,100;235,100])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],...
		'Mask Display','C(q,dq)dq')


%     Finished composite block ['voltage-controlled',13,'arm/arm/Coriolis + centrifugal'].

set_param([sys,'/',['voltage-controlled',13,'arm/arm/Coriolis + centrifugal']],...
		'orientation',2,...
		'move name',0,...
		'position',[130,20,185,55])


%     Subsystem  ['voltage-controlled',13,'arm/arm/gravity'].

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

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

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

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

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

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

add_block('built-in/Gain',[sys,'/',['voltage-controlled',13,'arm/arm/gravity/Gain']])
set_param([sys,'/',['voltage-controlled',13,'arm/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,'/',['voltage-controlled',13,'arm/arm/gravity/Fcn2']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/gravity/Fcn2']],...
		'orientation',2,...
		'hide name',0,...
		'Expr','cos(u)',...
		'position',[210,25,250,45])

add_block('built-in/Gain',[sys,'/',['voltage-controlled',13,'arm/arm/gravity/Gain1']])
set_param([sys,'/',['voltage-controlled',13,'arm/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,'/',['voltage-controlled',13,'arm/arm/gravity/Sum5']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/gravity/Sum5']],...
		'orientation',2,...
		'hide name',0,...
		'position',[105,29,120,51])

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


%     Finished composite block ['voltage-controlled',13,'arm/arm/gravity'].

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

add_block('built-in/State-Space',[sys,'/',['voltage-controlled',13,'arm/arm/viscous friction']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/viscous friction']],...
		'orientation',2,...
		'move name',0,...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','F_v',...
		'Mask Type','Matrix Gain')
set_param([sys,'/',['voltage-controlled',13,'arm/arm/viscous friction']],...
		'Mask Dialogue','Matrix Gain.|Gain matrix:',...
		'Mask Translate','K = @1;')
set_param([sys,'/',['voltage-controlled',13,'arm/arm/viscous friction']],...
		'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,'/',['voltage-controlled',13,'arm/arm/Integrator']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/Integrator']],...
		'hide name',0,...
		'Initial','[0 0]',...
		'position',[205,140,230,170])

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

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


%     Subsystem  ['voltage-controlled',13,'arm/arm/resolved acc'].

new_system([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],'Location',[139,197,433,294])

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

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

add_block('built-in/MATLAB Fcn',[sys,'/',['voltage-controlled',13,'arm/arm/resolved acc/invB',13,'']])
set_param([sys,'/',['voltage-controlled',13,'arm/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,38,240,62])

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

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

add_block('built-in/Inport',[sys,'/',['voltage-controlled',13,'arm/arm/resolved acc/tau-tau''']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc/tau-tau''']],...
		'position',[10,20,30,40])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],[110,70;135,70])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],[35,70;45,70])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],[245,50;255,50])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],[35,30;135,30])
add_line([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],[170,50;180,50])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/resolved acc']],...
		'Mask Display','inv(B(q))')


%     Finished composite block ['voltage-controlled',13,'arm/arm/resolved acc'].

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

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

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

add_block('built-in/Inport',[sys,'/',['voltage-controlled',13,'arm/arm/tau']])
set_param([sys,'/',['voltage-controlled',13,'arm/arm/tau']],...
		'position',[10,140,30,160])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[125,40;50,40;50,135;80,135])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[35,150;80,150])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[295,155;310,155;310,200;115,200;125,165])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[310,155;310,30;190,30])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[235,155;243,155;243,95;180,95])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[190,155;200,155])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[235,155;260,155])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[110,145;125,145])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[310,200;310,235;180,235])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[135,95;65,95;65,120;80,120])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[135,235;65,235;65,165;80,165])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[243,115;350,115])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[243,95;243,45;190,45])
add_line([sys,'/',['voltage-controlled',13,'arm/arm']],[310,155;350,155])
set_param([sys,'/',['voltage-controlled',13,'arm/arm']],...
		'Mask Display','inv(B(q))(tau-tau'')')


%     Finished composite block ['voltage-controlled',13,'arm/arm'].

set_param([sys,'/',['voltage-controlled',13,'arm/arm']],...
		'move name',0,...
		'position',[155,81,250,119])

add_block('built-in/To Workspace',[sys,'/',['voltage-controlled',13,'arm/To Workspace1']])
set_param([sys,'/',['voltage-controlled',13,'arm/To Workspace1']],...
		'hide name',0,...
		'mat-name','tau',...
		'buffer','[5001,1,Ts]',...
		'position',[155,145,205,165])

add_block('built-in/Sum',[sys,'/',['voltage-controlled',13,'arm/Sum1']])
set_param([sys,'/',['voltage-controlled',13,'arm/Sum1']],...
		'hide name',0,...
		'inputs','-+',...
		'position',[110,84,130,111])

add_block('built-in/State-Space',[sys,'/',['voltage-controlled',13,'arm/Matrix',13,'Gain5']])
set_param([sys,'/',['voltage-controlled',13,'arm/Matrix',13,'Gain5']],...
		'hide name',0,...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','G_r',...
		'Mask Type','Matrix Gain')
set_param([sys,'/',['voltage-controlled',13,'arm/Matrix',13,'Gain5']],...
		'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,'/',['voltage-controlled',13,'arm/Matrix',13,'Gain5']],...
		'Mask Entries','G_r\/',...
		'position',[50,91,80,119])

add_block('built-in/Inport',[sys,'/',['voltage-controlled',13,'arm/Vc']])
set_param([sys,'/',['voltage-controlled',13,'arm/Vc']],...
		'position',[10,95,30,115])

add_block('built-in/State-Space',[sys,'/',['voltage-controlled',13,'arm/electrical friction']])
set_param([sys,'/',['voltage-controlled',13,'arm/electrical friction']],...
		'orientation',2,...
		'move name',0,...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','F_e',...
		'Mask Type','Matrix Gain')
set_param([sys,'/',['voltage-controlled',13,'arm/electrical friction']],...
		'Mask Dialogue','Matrix Gain.|Gain matrix:',...
		'Mask Translate','K = @1;')
set_param([sys,'/',['voltage-controlled',13,'arm/electrical friction']],...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','F_e\/',...
		'position',[185,25,215,55])
add_line([sys,'/',['voltage-controlled',13,'arm']],[35,105;45,105])
add_line([sys,'/',['voltage-controlled',13,'arm']],[135,100;150,100])
add_line([sys,'/',['voltage-controlled',13,'arm']],[85,105;105,105])
add_line([sys,'/',['voltage-controlled',13,'arm']],[180,40;90,40;90,90;105,90])
add_line([sys,'/',['voltage-controlled',13,'arm']],[255,90;270,90;270,40;220,40])
add_line([sys,'/',['voltage-controlled',13,'arm']],[255,110;295,110])
add_line([sys,'/',['voltage-controlled',13,'arm']],[270,90;270,155;295,155])
add_line([sys,'/',['voltage-controlled',13,'arm']],[135,100;135,155;150,155])
set_param([sys,'/',['voltage-controlled',13,'arm']],...
		'Mask Display','M')


%     Finished composite block ['voltage-controlled',13,'arm'].

set_param([sys,'/',['voltage-controlled',13,'arm']],...
		'move name',0,...
		'Font Name','Arial',...
		'position',[410,202,445,238])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space1'])
set_param([sys,'/','Discrete State-Space1'],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','k_fv',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','k_fv')
set_param([sys,'/','Discrete State-Space1'],...
		'position',[140,139,170,171])

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','k_fa',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','k_fa')
set_param([sys,'/','Discrete State-Space'],...
		'position',[140,104,170,136])

add_block('built-in/To Workspace',[sys,'/','To Workspace3'])
set_param([sys,'/','To Workspace3'],...
		'hide name',0,...
		'Font Name','Arial',...
		'mat-name','q',...
		'buffer','[5001,1,Ts]',...
		'position',[485,200,535,220])

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,208,55,232])

add_block('built-in/State-Space',[sys,'/',['Matrix',13,'Gain12']])
set_param([sys,'/',['Matrix',13,'Gain12']],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','k_fp',...
		'Mask Type','Matrix Gain')
set_param([sys,'/',['Matrix',13,'Gain12']],...
		'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,'/',['Matrix',13,'Gain12']],...
		'Mask Entries','k_fp\/',...
		'position',[75,204,105,236])

add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
		'hide name',0,...
		'Font Name','Arial',...
		'inputs','+-',...
		'position',[130,214,150,241])

add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
		'hide name',0,...
		'Font Name','Arial',...
		'inputs','+++-',...
		'position',[240,191,260,254])

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,108,55,132])


%     Subsystem  'computed torque'.

new_system([sys,'/','computed torque'])
set_param([sys,'/','computed torque'],'Location',[70,212,517,389])

add_block('built-in/Inport',[sys,'/','computed torque/dq_d'])
set_param([sys,'/','computed torque/dq_d'],...
		'Port','2',...
		'position',[15,130,35,150])

add_block('built-in/Inport',[sys,'/','computed torque/q_d'])
set_param([sys,'/','computed torque/q_d'],...
		'position',[15,40,35,60])

add_block('built-in/Demux',[sys,'/','computed torque/Demux1'])
set_param([sys,'/','computed torque/Demux1'],...
		'hide name',0,...
		'outputs','2',...
		'position',[115,129,160,151])


%     Subsystem  ['computed torque/gravity',13,'compensation'].

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

add_block('built-in/Inport',[sys,'/',['computed torque/gravity',13,'compensation/in_1']])
set_param([sys,'/',['computed torque/gravity',13,'compensation/in_1']],...
		'orientation',2,...
		'hide name',0,...
		'position',[465,50,485,70])

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

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

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

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

add_block('built-in/Discrete State-Space',[sys,'/',['computed torque/gravity',13,'compensation/Discrete State-Space2']])
set_param([sys,'/',['computed torque/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,'/',['computed torque/gravity',13,'compensation/Discrete State-Space2']],...
		'Mask Display','Sampler',...
		'position',[400,44,450,76])

add_block('built-in/Gain',[sys,'/',['computed torque/gravity',13,'compensation/Gain']])
set_param([sys,'/',['computed torque/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/Fcn',[sys,'/',['computed torque/gravity',13,'compensation/Fcn2']])
set_param([sys,'/',['computed torque/gravity',13,'compensation/Fcn2']],...
		'orientation',2,...
		'hide name',0,...
		'Expr','cos(u)',...
		'position',[210,25,250,45])

add_block('built-in/Gain',[sys,'/',['computed torque/gravity',13,'compensation/Gain1']])
set_param([sys,'/',['computed torque/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/Sum',[sys,'/',['computed torque/gravity',13,'compensation/Sum5']])
set_param([sys,'/',['computed torque/gravity',13,'compensation/Sum5']],...
		'orientation',2,...
		'hide name',0,...
		'position',[105,29,120,51])

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


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

set_param([sys,'/',['computed torque/gravity',13,'compensation']],...
		'move name',0,...
		'position',[125,32,155,68])

add_block('built-in/Sum',[sys,'/','computed torque/Sum4'])
set_param([sys,'/','computed torque/Sum4'],...
		'hide name',0,...
		'position',[310,42,330,73])

add_block('built-in/Discrete State-Space',[sys,'/','computed torque/Discrete State-Space'])
set_param([sys,'/','computed torque/Discrete State-Space'],...
		'hide name',0,...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','K_pr',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','K_pr')
set_param([sys,'/','computed torque/Discrete State-Space'],...
		'position',[350,45,385,75])

add_block('built-in/Outport',[sys,'/','computed torque/tau_d'])
set_param([sys,'/','computed torque/tau_d'],...
		'position',[410,50,430,70])

add_block('built-in/Product',[sys,'/','computed torque/Product'])
set_param([sys,'/','computed torque/Product'],...
		'position',[235,93,265,117])

add_block('built-in/Fcn',[sys,'/','computed torque/Fcn'])
set_param([sys,'/','computed torque/Fcn'],...
		'hide name',0,...
		'Expr','2*a(1)*pi_l(3)*cos(u(2))',...
		'position',[75,88,205,112])
add_line([sys,'/','computed torque'],[390,60;405,60])
add_line([sys,'/','computed torque'],[40,50;120,50])
add_line([sys,'/','computed torque'],[40,140;110,140])
add_line([sys,'/','computed torque'],[210,100;230,100])
add_line([sys,'/','computed torque'],[165,135;215,135;215,110;230,110])
add_line([sys,'/','computed torque'],[160,50;305,50])
add_line([sys,'/','computed torque'],[270,105;285,105;285,65;305,65])
add_line([sys,'/','computed torque'],[335,60;345,60])
add_line([sys,'/','computed torque'],[50,50;50,100;70,100])
set_param([sys,'/','computed torque'],...
		'Mask Display','tau_d')


%     Finished composite block 'computed torque'.

set_param([sys,'/','computed torque'],...
		'move name',0,...
		'Font Name','Arial',...
		'position',[240,68,290,97])

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


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


%     Finished composite block 'Subsystem8'.

set_param([sys,'/','Subsystem8'],...
		'orientation',2,...
		'hide name',0,...
		'Font Name','Arial',...
		'Drop Shadow',4,...
		'position',[465,335,535,366])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space6'])
set_param([sys,'/','Discrete State-Space6'],...
		'orientation',2,...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','k_tv',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','k_tv')
set_param([sys,'/','Discrete State-Space6'],...
		'position',[300,259,330,291])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space5'])
set_param([sys,'/','Discrete State-Space5'],...
		'orientation',2,...
		'hide name',0,...
		'Font Name','Arial',...
		'A','0',...
		'B','0',...
		'C','zeros(2,1)',...
		'D','k_tp',...
		'X0','0',...
		'Sample time','Tc',...
		'Mask Display','k_tp')
set_param([sys,'/','Discrete State-Space5'],...
		'position',[300,299,330,331])

add_block('built-in/State-Space',[sys,'/',['Matrix',13,'Gain13']])
set_param([sys,'/',['Matrix',13,'Gain13']],...
		'hide name',0,...
		'Font Name','Arial',...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','K_v',...
		'Mask Type','Matrix Gain')
set_param([sys,'/',['Matrix',13,'Gain13']],...
		'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,'/',['Matrix',13,'Gain13']],...
		'Mask Entries','K_v\/',...
		'position',[275,209,305,241])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State-Space2'])
set_param([sys,'/','Discrete State-Space2'],...
		'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-Space2'],...
		'position',[170,214,200,246])

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

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

add_block('built-in/Note',[sys,'/','dq'])
set_param([sys,'/','dq'],...
		'Font Name','Arial',...
		'position',[450,209,455,216])
add_line(sys,[155,230;165,230])
add_line(sys,[110,220;125,220])
add_line(sys,[460,15;475,15])
add_line(sys,[60,220;70,220])
add_line(sys,[60,155;135,155])
add_line(sys,[60,120;135,120])
add_line(sys,[295,315;110,315;110,235;125,235])
add_line(sys,[450,230;455,230;455,275;335,275])
add_line(sys,[60,220;60,75;235,75])
add_line(sys,[75,120;75,90;235,90])
add_line(sys,[400,220;405,220])
add_line(sys,[360,225;370,225])
add_line(sys,[295,275;220,275;220,245;235,245])
add_line(sys,[175,155;210,155;210,215;235,215])
add_line(sys,[295,85;360,85;370,210])
add_line(sys,[450,210;480,210])
add_line(sys,[310,225;315,225])
add_line(sys,[265,225;270,225])
add_line(sys,[465,210;465,315;335,315])
add_line(sys,[175,120;220,120;220,200;235,200])
add_line(sys,[205,230;235,230])

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
