function [ret,x0,str,ts,xts]=ani_cntr(t,x,u,flag); %ANI_CNTR is the M-file description of the SIMULINK system named ANI_CNTR. % The block-diagram can be displayed by typing: ANI_CNTR. % % SYS=ANI_CNTR(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 ANI_CNTR 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 ANI_CNTR with a FLAG of zero: % [SIZES]=ANI_CNTR([],[],[],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. % % Generated by SIMULINK % Copyright 1997 by Peter C. Jones and Scott D. Tepavich. % All Rights Reserved. % 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',[4,52,836,507]) open_system(sys) end; set_param(sys,'algorithm', 'RK-45') set_param(sys,'Start time', '0.0') set_param(sys,'Stop time', '5') set_param(sys,'Min step size', '0.004') set_param(sys,'Max step size', '0.004') set_param(sys,'Relative error','1e-6') set_param(sys,'Return vars', '') set_param(sys,'AssignWideVectorLines','on'); add_block('built-in/MATLAB Fcn',[sys,'/','Animation']) set_param([sys,'/','Animation'],... 'MATLAB Fcn','ani_pend',... 'Output Width','1',... 'Mask Display','plot(0,0,100,100,[50,55,45,50,60],[30,20,20,30,80])',... 'Mask Type','Pendulum') set_param([sys,'/','Animation'],... 'Mask Dialogue','Animates the pendulum arm. Displays \ndisturbance and control directions.',... 'Mask Help','This block uses a MATLAB figure window to animate the pendulum.\nSee the M-file ani_pend.m.') set_param([sys,'/','Animation'],... 'position',[590,163,650,197]) add_block('built-in/MATLAB Fcn',[sys,'/',['Neural Net',13,'With Delayed Inputs']]) set_param([sys,'/',['Neural Net',13,'With Delayed Inputs']],... 'orientation',2,... 'MATLAB Fcn','anndelay(u,Xes,W)') set_param([sys,'/',['Neural Net',13,'With Delayed Inputs']],... 'Mask Display','plot(0,0,100,100,50+5*cos(.1*pi*[0:20]),50+5*sin(.1*pi*[0:20]),[25 55 55 55;45 75 75 75;45 85 85 85],[50 50 50 50;50 25 60 75;50 25 60 75])',... 'Mask Type','ANN') set_param([sys,'/',['Neural Net',13,'With Delayed Inputs']],... 'position',[330,231,400,279]) add_block('built-in/Mux',[sys,'/','Mux']) set_param([sys,'/','Mux'],... 'inputs','3',... 'position',[540,162,575,198]) % Subsystem 'Arm Angle'. new_system([sys,'/','Arm Angle']) set_param([sys,'/','Arm Angle'],'Location',[0,59,274,252]) add_block('built-in/Inport',[sys,'/','Arm Angle/x']) set_param([sys,'/','Arm Angle/x'],... 'position',[65,55,85,75]) add_block('built-in/S-Function',[sys,'/',['Arm Angle/S-function',13,'M-file which plots',13,'lines',13,'']]) set_param([sys,'/',['Arm Angle/S-function',13,'M-file which plots',13,'lines',13,'']],... 'function name','sfunyst',... 'parameters','ax, color, npts, dt',... 'position',[130,55,180,75]) add_line([sys,'/','Arm Angle'],[90,65;125,65]) set_param([sys,'/','Arm Angle'],... 'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',... 'Mask Type','Storage scope.') set_param([sys,'/','Arm Angle'],... 'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):') set_param([sys,'/','Arm Angle'],... 'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;') set_param([sys,'/','Arm Angle'],... 'Mask Help','This block uses a MATLAB figure window to plot the input signal. The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer. Line type must be in quotes. See the M-file sfunyst.m.') set_param([sys,'/','Arm Angle'],... 'Mask Entries','5\/-25\/25\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/') % Finished composite block 'Arm Angle'. set_param([sys,'/','Arm Angle'],... 'position',[745,160,775,200]) add_block('built-in/Gain',[sys,'/','To Deg']) set_param([sys,'/','To Deg'],... 'Gain','180/pi',... 'position',[665,153,730,207]) add_block('built-in/Transport Delay',[sys,'/',['Time',13,'Delay',13,'(.16 ms)']]) set_param([sys,'/',['Time',13,'Delay',13,'(.16 ms)']],... 'Delay Time','.016',... 'position',[385,160,425,190]) add_block('built-in/Sum',[sys,'/',['Disturbed',13,'Plant',13,'Output']]) set_param([sys,'/',['Disturbed',13,'Plant',13,'Output']],... 'position',[455,154,480,181]) add_block('built-in/Transfer Fcn',[sys,'/','Plant']) set_param([sys,'/','Plant'],... 'Numerator','[1.05]',... 'Denominator','[.037 .963 -1]',... 'position',[250,154,370,196]) % Subsystem 'Down-pulse'. new_system([sys,'/','Down-pulse']) set_param([sys,'/','Down-pulse'],'Location',[158,441,759,682]) add_block('built-in/Outport',[sys,'/','Down-pulse/out_1']) set_param([sys,'/','Down-pulse/out_1'],... 'hide name',0,... 'position',[560,105,580,125]) add_block('built-in/Gain',[sys,'/','Down-pulse/Gain']) set_param([sys,'/','Down-pulse/Gain'],... 'hide name',0,... 'Gain','ht',... 'position',[510,102,535,128]) add_block('built-in/Product',[sys,'/','Down-pulse/Product']) set_param([sys,'/','Down-pulse/Product'],... 'hide name',0,... 'position',[455,105,480,125]) add_block('built-in/Logical Operator',[sys,'/',['Down-pulse/Logical',13,'Operator1']]) set_param([sys,'/',['Down-pulse/Logical',13,'Operator1']],... 'Operator','NOT',... 'Number of Input Ports','1',... 'position',[355,38,385,62]) add_block('built-in/Logical Operator',[sys,'/',['Down-pulse/Logical',13,'Operator']]) set_param([sys,'/',['Down-pulse/Logical',13,'Operator']],... 'Operator','XOR',... 'position',[285,38,315,62]) add_block('built-in/Constant',[sys,'/','Down-pulse/Constant1']) set_param([sys,'/','Down-pulse/Constant1'],... 'Value','stt',... 'position',[295,149,320,171]) add_block('built-in/Clock',[sys,'/','Down-pulse/Clock1']) set_param([sys,'/','Down-pulse/Clock1'],... 'hide name',0,... 'position',[295,100,315,120]) add_block('built-in/Relational Operator',[sys,'/',['Down-pulse/Relational',13,'operator']]) set_param([sys,'/',['Down-pulse/Relational',13,'operator']],... 'hide name',0,... 'position',[370,102,400,133]) add_block('built-in/Sum',[sys,'/','Down-pulse/Sum1']) set_param([sys,'/','Down-pulse/Sum1'],... 'hide name',0,... 'inputs','+-',... 'position',[130,120,150,140]) add_block('built-in/Sum',[sys,'/','Down-pulse/Sum']) set_param([sys,'/','Down-pulse/Sum'],... 'hide name',0,... 'inputs','+-',... 'position',[135,35,155,55]) add_block('built-in/Constant',[sys,'/','Down-pulse/Constant']) set_param([sys,'/','Down-pulse/Constant'],... 'position',[25,30,45,50]) add_block('built-in/Unit Delay',[sys,'/','Down-pulse/Unit Delay']) set_param([sys,'/','Down-pulse/Unit Delay'],... 'orientation',2,... 'Sample time','[Ts,st1]',... 'position',[145,75,195,95]) add_block('built-in/Unit Delay',[sys,'/','Down-pulse/Unit Delay1']) set_param([sys,'/','Down-pulse/Unit Delay1'],... 'orientation',2,... 'Sample time','[Ts,st2]',... 'x0','ini',... 'position',[140,165,190,185]) add_line([sys,'/','Down-pulse'],[390,50;430,50;430,110;450,110]) add_line([sys,'/','Down-pulse'],[320,50;350,50]) add_line([sys,'/','Down-pulse'],[325,160;345,160;345,125;365,125]) add_line([sys,'/','Down-pulse'],[540,115;555,115]) add_line([sys,'/','Down-pulse'],[485,115;505,115]) add_line([sys,'/','Down-pulse'],[405,120;450,120]) add_line([sys,'/','Down-pulse'],[320,110;365,110]) add_line([sys,'/','Down-pulse'],[140,85;105,85;105,50;130,50]) add_line([sys,'/','Down-pulse'],[160,45;230,45;230,85;200,85]) add_line([sys,'/','Down-pulse'],[50,40;130,40]) add_line([sys,'/','Down-pulse'],[155,130;210,130;210,175;195,175]) add_line([sys,'/','Down-pulse'],[135,175;100,175;100,135;125,135]) add_line([sys,'/','Down-pulse'],[50,40;70,40;70,125;125,125]) add_line([sys,'/','Down-pulse'],[160,45;280,45]) add_line([sys,'/','Down-pulse'],[155,130;245,130;245,55;280,55]) set_param([sys,'/','Down-pulse'],... 'Mask Display','plot(0,0,100,100,[90,75,75,60,60,35,35,20,20,10],[20,20,80,80,20,20,80,80,20,20])',... 'Mask Type','Pulse Generator') set_param([sys,'/','Down-pulse'],... 'Mask Dialogue','Pulse Generator.|Pulse period (secs):|Pulse width:|Pulse height:|Pulse start time:') set_param([sys,'/','Down-pulse'],... 'Mask Translate','Ts=@1; du=@2; ht=@3; stt=@4; ini=ones(length(ht),1); st1=rem(stt,Ts); st2=rem(stt+du,Ts);if(Ts<=1.2*du),ini=zeros(length(ht),1);end;') set_param([sys,'/','Down-pulse'],... 'Mask Help','Pulse generator which ensures pulse\ntransitions are hit. Provides a vector of pulses when the height is entered as a vector.\nUnmask to see how it works.') set_param([sys,'/','Down-pulse'],... 'Mask Entries','100\/.05\/-.3491\/2\/') % Finished composite block 'Down-pulse'. set_param([sys,'/','Down-pulse'],... 'position',[195,30,235,70]) % Subsystem 'Up-Pulse'. new_system([sys,'/','Up-Pulse']) set_param([sys,'/','Up-Pulse'],'Location',[158,441,759,682]) add_block('built-in/Outport',[sys,'/','Up-Pulse/out_1']) set_param([sys,'/','Up-Pulse/out_1'],... 'hide name',0,... 'position',[560,105,580,125]) add_block('built-in/Gain',[sys,'/','Up-Pulse/Gain']) set_param([sys,'/','Up-Pulse/Gain'],... 'hide name',0,... 'Gain','ht',... 'position',[510,102,535,128]) add_block('built-in/Product',[sys,'/','Up-Pulse/Product']) set_param([sys,'/','Up-Pulse/Product'],... 'hide name',0,... 'position',[455,105,480,125]) add_block('built-in/Logical Operator',[sys,'/',['Up-Pulse/Logical',13,'Operator1']]) set_param([sys,'/',['Up-Pulse/Logical',13,'Operator1']],... 'Operator','NOT',... 'Number of Input Ports','1',... 'position',[355,38,385,62]) add_block('built-in/Logical Operator',[sys,'/',['Up-Pulse/Logical',13,'Operator']]) set_param([sys,'/',['Up-Pulse/Logical',13,'Operator']],... 'Operator','XOR',... 'position',[285,38,315,62]) add_block('built-in/Constant',[sys,'/','Up-Pulse/Constant1']) set_param([sys,'/','Up-Pulse/Constant1'],... 'Value','stt',... 'position',[295,149,320,171]) add_block('built-in/Clock',[sys,'/','Up-Pulse/Clock1']) set_param([sys,'/','Up-Pulse/Clock1'],... 'hide name',0,... 'position',[295,100,315,120]) add_block('built-in/Relational Operator',[sys,'/',['Up-Pulse/Relational',13,'operator']]) set_param([sys,'/',['Up-Pulse/Relational',13,'operator']],... 'hide name',0,... 'position',[370,102,400,133]) add_block('built-in/Sum',[sys,'/','Up-Pulse/Sum1']) set_param([sys,'/','Up-Pulse/Sum1'],... 'hide name',0,... 'inputs','+-',... 'position',[130,120,150,140]) add_block('built-in/Sum',[sys,'/','Up-Pulse/Sum']) set_param([sys,'/','Up-Pulse/Sum'],... 'hide name',0,... 'inputs','+-',... 'position',[135,35,155,55]) add_block('built-in/Constant',[sys,'/','Up-Pulse/Constant']) set_param([sys,'/','Up-Pulse/Constant'],... 'position',[25,30,45,50]) add_block('built-in/Unit Delay',[sys,'/','Up-Pulse/Unit Delay']) set_param([sys,'/','Up-Pulse/Unit Delay'],... 'orientation',2,... 'Sample time','[Ts,st1]',... 'position',[145,75,195,95]) add_block('built-in/Unit Delay',[sys,'/','Up-Pulse/Unit Delay1']) set_param([sys,'/','Up-Pulse/Unit Delay1'],... 'orientation',2,... 'Sample time','[Ts,st2]',... 'x0','ini',... 'position',[140,165,190,185]) add_line([sys,'/','Up-Pulse'],[390,50;430,50;430,110;450,110]) add_line([sys,'/','Up-Pulse'],[320,50;350,50]) add_line([sys,'/','Up-Pulse'],[325,160;345,160;345,125;365,125]) add_line([sys,'/','Up-Pulse'],[540,115;555,115]) add_line([sys,'/','Up-Pulse'],[485,115;505,115]) add_line([sys,'/','Up-Pulse'],[405,120;450,120]) add_line([sys,'/','Up-Pulse'],[320,110;365,110]) add_line([sys,'/','Up-Pulse'],[140,85;105,85;105,50;130,50]) add_line([sys,'/','Up-Pulse'],[160,45;230,45;230,85;200,85]) add_line([sys,'/','Up-Pulse'],[50,40;130,40]) add_line([sys,'/','Up-Pulse'],[155,130;210,130;210,175;195,175]) add_line([sys,'/','Up-Pulse'],[135,175;100,175;100,135;125,135]) add_line([sys,'/','Up-Pulse'],[50,40;70,40;70,125;125,125]) add_line([sys,'/','Up-Pulse'],[160,45;280,45]) add_line([sys,'/','Up-Pulse'],[155,130;245,130;245,55;280,55]) set_param([sys,'/','Up-Pulse'],... 'Mask Display','plot(0,0,100,100,[90,75,75,60,60,35,35,20,20,10],[20,20,80,80,20,20,80,80,20,20])',... 'Mask Type','Pulse Generator') set_param([sys,'/','Up-Pulse'],... 'Mask Dialogue','Pulse Generator.|Pulse period (secs):|Pulse width:|Pulse height:|Pulse start time:') set_param([sys,'/','Up-Pulse'],... 'Mask Translate','Ts=@1; du=@2; ht=@3; stt=@4; ini=ones(length(ht),1); st1=rem(stt,Ts); st2=rem(stt+du,Ts);if(Ts<=1.2*du),ini=zeros(length(ht),1);end;') set_param([sys,'/','Up-Pulse'],... 'Mask Help','Pulse generator which ensures pulse\ntransitions are hit. Provides a vector of pulses when the height is entered as a vector.\nUnmask to see how it works.') set_param([sys,'/','Up-Pulse'],... 'Mask Entries','100\/.05\/.17453\/0.05\/') % Finished composite block 'Up-Pulse'. set_param([sys,'/','Up-Pulse'],... 'position',[305,92,340,128]) add_block('built-in/Sum',[sys,'/','Sum']) set_param([sys,'/','Sum'],... 'inputs','+++',... 'position',[360,62,380,98]) add_block('built-in/Signal Generator',[sys,'/',['Random',13,'Noise']]) set_param([sys,'/',['Random',13,'Noise']],... 'Peak','0.040000',... 'Peak Range','0.170000',... 'Freq','0.000000',... 'Freq Range','5.000000',... 'Wave','Rnd',... 'Units','Rads',... 'position',[250,63,295,97]) % Subsystem 'D'. new_system([sys,'/','D']) set_param([sys,'/','D'],'Location',[0,59,274,252]) add_block('built-in/Inport',[sys,'/','D/x']) set_param([sys,'/','D/x'],... 'position',[65,55,85,75]) add_block('built-in/S-Function',[sys,'/',['D/S-function',13,'M-file which plots',13,'lines',13,'']]) set_param([sys,'/',['D/S-function',13,'M-file which plots',13,'lines',13,'']],... 'function name','sfunyst',... 'parameters','ax, color, npts, dt',... 'position',[130,55,180,75]) add_line([sys,'/','D'],[90,65;125,65]) set_param([sys,'/','D'],... 'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',... 'Mask Type','Storage scope.') set_param([sys,'/','D'],... 'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):') set_param([sys,'/','D'],... 'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;') set_param([sys,'/','D'],... 'Mask Help','This block uses a MATLAB figure window to plot the input signal. The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer. Line type must be in quotes. See the M-file sfunyst.m.') set_param([sys,'/','D'],... 'Mask Entries','5\/-.4\/.4\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/') % Finished composite block 'D'. set_param([sys,'/','D'],... 'orientation',3,... 'position',[415,20,445,65]) % Subsystem 'C'. new_system([sys,'/','C']) set_param([sys,'/','C'],'Location',[0,59,274,252]) add_block('built-in/Inport',[sys,'/','C/x']) set_param([sys,'/','C/x'],... 'position',[65,55,85,75]) add_block('built-in/S-Function',[sys,'/',['C/S-function',13,'M-file which plots',13,'lines',13,'']]) set_param([sys,'/',['C/S-function',13,'M-file which plots',13,'lines',13,'']],... 'function name','sfunyst',... 'parameters','ax, color, npts, dt',... 'position',[130,55,180,75]) add_line([sys,'/','C'],[90,65;125,65]) set_param([sys,'/','C'],... 'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',... 'Mask Type','Storage scope.') set_param([sys,'/','C'],... 'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):') set_param([sys,'/','C'],... 'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;') set_param([sys,'/','C'],... 'Mask Help','This block uses a MATLAB figure window to plot the input signal. The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer. Line type must be in quotes. See the M-file sfunyst.m.') set_param([sys,'/','C'],... 'Mask Entries','5\/-15\/15\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/') % Finished composite block 'C'. set_param([sys,'/','C'],... 'orientation',1,... 'position',[215,335,245,380]) add_line(sys,[325,255;230,255;230,175;245,175]) add_line(sys,[240,50;345,50;355,70]) add_line(sys,[385,80;430,80;430,160;450,160]) add_line(sys,[345,110;355,90]) add_line(sys,[300,80;355,80]) add_line(sys,[375,175;380,175]) add_line(sys,[430,175;450,175]) add_line(sys,[485,170;500,170;500,255;405,255]) add_line(sys,[735,180;740,180]) add_line(sys,[655,180;660,180]) add_line(sys,[580,180;585,180]) add_line(sys,[485,170;535,170]) add_line(sys,[430,80;430,70]) add_line(sys,[230,255;230,330]) add_line(sys,[430,80;795,80;795,255;515,255;515,180;535,180]) add_line(sys,[230,305;525,305;535,190]) 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