function [ret,x0,str,ts,xts]=td_250(t,x,u,flag); %TD_250 is the M-file description of the SIMULINK system named TD_250. % The block-diagram can be displayed by typing: TD_250. % % SYS=TD_250(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 TD_250 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 TD_250 with a FLAG of zero: % [SIZES]=TD_250([],[],[],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',[27,159,736,542]) 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', '') % Subsystem ['Manual',13,'Graph']. new_system([sys,'/',['Manual',13,'Graph']]) set_param([sys,'/',['Manual',13,'Graph']],'Location',[0,59,274,252]) add_block('built-in/Inport',[sys,'/',['Manual',13,'Graph/x']]) set_param([sys,'/',['Manual',13,'Graph/x']],... 'position',[65,55,85,75]) add_block('built-in/S-Function',[sys,'/',['Manual',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']]) set_param([sys,'/',['Manual',13,'Graph/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,'/',['Manual',13,'Graph']],[90,65;125,65]) set_param([sys,'/',['Manual',13,'Graph']],... '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,'/',['Manual',13,'Graph']],... '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,'/',['Manual',13,'Graph']],... 'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;') set_param([sys,'/',['Manual',13,'Graph']],... '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,'/',['Manual',13,'Graph']],... 'Mask Entries','5\/-1\/1\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/') % Finished composite block ['Manual',13,'Graph']. set_param([sys,'/',['Manual',13,'Graph']],... 'orientation',2,... 'position',[195,125,225,165]) add_block('built-in/Clock',[sys,'/','Clock']) set_param([sys,'/','Clock'],... 'position',[15,100,35,120]) add_block('built-in/Step Fcn',[sys,'/',['Input',13,'Angle']]) set_param([sys,'/',['Input',13,'Angle']],... 'Time','0',... 'After','0',... 'Mask Display','',... 'position',[15,215,35,235]) add_block('built-in/Sum',[sys,'/','error']) set_param([sys,'/','error'],... 'inputs','+-',... 'position',[85,218,110,247]) add_block('built-in/Transfer Fcn',[sys,'/','Plant']) set_param([sys,'/','Plant'],... 'Numerator','[1.05]',... 'Denominator','[.037 .963 -1]',... 'position',[250,214,370,256]) add_block('built-in/To Workspace',[sys,'/',['Generated',13,'Manual Signal']]) set_param([sys,'/',['Generated',13,'Manual Signal']],... 'mat-name','ThD',... 'buffer','10000',... 'position',[275,137,325,153]) add_block('built-in/Sum',[sys,'/',['Disturbed',13,'Plant',13,'Output']]) set_param([sys,'/',['Disturbed',13,'Plant',13,'Output']],... 'position',[465,214,490,241]) add_block('built-in/To Workspace',[sys,'/','To Workspace']) set_param([sys,'/','To Workspace'],... 'mat-name','t',... 'buffer','10000',... 'position',[65,102,115,118]) % Subsystem 'ThOut Graph'. new_system([sys,'/','ThOut Graph']) set_param([sys,'/','ThOut Graph'],'Location',[0,59,274,252]) add_block('built-in/Inport',[sys,'/','ThOut Graph/x']) set_param([sys,'/','ThOut Graph/x'],... 'position',[65,55,85,75]) add_block('built-in/S-Function',[sys,'/',['ThOut Graph/S-function',13,'M-file which plots',13,'lines',13,'']]) set_param([sys,'/',['ThOut Graph/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,'/','ThOut Graph'],[90,65;125,65]) set_param([sys,'/','ThOut Graph'],... '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,'/','ThOut Graph'],... '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,'/','ThOut Graph'],... 'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;') set_param([sys,'/','ThOut Graph'],... '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,'/','ThOut Graph'],... 'Mask Entries','5\/-1\/1\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/') % Finished composite block 'ThOut Graph'. set_param([sys,'/','ThOut Graph'],... 'position',[645,160,675,200]) add_block('built-in/To Workspace',[sys,'/','Output Angle']) set_param([sys,'/','Output Angle'],... 'mat-name','ThOut',... 'buffer','10000',... 'position',[635,222,685,238]) % 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',[135,0,175,40]) % 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',[260,62,295,98]) add_block('built-in/Sum',[sys,'/','Sum']) set_param([sys,'/','Sum'],... 'inputs','+++',... 'position',[360,32,380,68]) % Subsystem ['Disturbance',13,'Signal']. new_system([sys,'/',['Disturbance',13,'Signal']]) set_param([sys,'/',['Disturbance',13,'Signal']],'Location',[0,59,274,252]) add_block('built-in/Inport',[sys,'/',['Disturbance',13,'Signal/x']]) set_param([sys,'/',['Disturbance',13,'Signal/x']],... 'position',[65,55,85,75]) add_block('built-in/S-Function',[sys,'/',['Disturbance',13,'Signal/S-function',13,'M-file which plots',13,'lines',13,'']]) set_param([sys,'/',['Disturbance',13,'Signal/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,'/',['Disturbance',13,'Signal']],[90,65;125,65]) set_param([sys,'/',['Disturbance',13,'Signal']],... '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,'/',['Disturbance',13,'Signal']],... '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,'/',['Disturbance',13,'Signal']],... 'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;') set_param([sys,'/',['Disturbance',13,'Signal']],... '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,'/',['Disturbance',13,'Signal']],... 'Mask Entries','5\/-1\/1\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/') % Finished composite block ['Disturbance',13,'Signal']. set_param([sys,'/',['Disturbance',13,'Signal']],... 'position',[480,30,510,70]) add_block('built-in/To Workspace',[sys,'/','Save Disturbance']) set_param([sys,'/','Save Disturbance'],... 'mat-name','D',... 'buffer','10000',... 'position',[475,112,525,128]) 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',[200,33,245,67]) 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,220,425,250]) add_block('built-in/Gain',[sys,'/','Gain']) set_param([sys,'/','Gain'],... 'Gain','10',... 'position',[140,206,190,264]) add_block('built-in/Gain',[sys,'/','Gain1']) set_param([sys,'/','Gain1'],... 'orientation',2,... 'Gain','2.81',... 'position',[255,291,305,349]) add_line(sys,[40,225;80,225]) add_line(sys,[115,235;135,235]) add_line(sys,[40,110;60,110]) add_line(sys,[195,235;245,235;245,145;270,145]) add_line(sys,[245,235;245,235]) add_line(sys,[250,145;230,145]) add_line(sys,[495,230;630,230]) add_line(sys,[600,230;600,180;640,180]) add_line(sys,[385,50;475,50]) add_line(sys,[180,20;345,20;355,40]) add_line(sys,[430,50;430,220;460,220]) add_line(sys,[430,120;470,120]) add_line(sys,[300,80;345,80;355,60]) add_line(sys,[250,50;355,50]) add_line(sys,[375,235;380,235]) add_line(sys,[430,235;460,235]) add_line(sys,[250,320;70,320;80,240]) add_line(sys,[600,220;600,320;310,320]) 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