ctest1_s.m

来自「FISMAT accommodates different arithmetic」· M 代码 · 共 141 行

M
141
字号
function [ret,x0,str,ts,xts]=ctest1_s(t,x,u,flag);%CTEST1_S	is the M-file description of the SIMULINK system named CTEST1_S.%	The block-diagram can be displayed by typing: CTEST1_S.%%	SYS=CTEST1_S(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 CTEST1_S 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 CTEST1_S with a FLAG of zero:%	[SIZES]=CTEST1_S([],[],[],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',[70,188,1028,576])     open_system(sys)end;set_param(sys,'algorithm',     'RK-45')set_param(sys,'Start time',    '0.0')set_param(sys,'Stop time',     '1')set_param(sys,'Min step size', '0.00001')set_param(sys,'Max step size', '0.001')set_param(sys,'Relative error','1e-3')set_param(sys,'Return vars',   '')add_block('built-in/Step Fcn',[sys,'/','Step Fcn'])set_param([sys,'/','Step Fcn'],...		'Time','0',...		'position',[30,55,50,75])add_block('built-in/Integrator',[sys,'/','Integrator'])set_param([sys,'/','Integrator'],...		'position',[90,55,110,75])add_block('built-in/S-Function',[sys,'/',['''ct1_c1'',0.1']])set_param([sys,'/',['''ct1_c1'',0.1']],...		'function name','neurofuz',...		'parameters','''ct1_c1'',0.1',...		'position',[170,53,240,77])add_block('built-in/To Workspace',[sys,'/','To Workspace'])set_param([sys,'/','To Workspace'],...		'mat-name','t',...		'position',[265,137,315,153])add_block('built-in/Clock',[sys,'/','Clock'])set_param([sys,'/','Clock'],...		'position',[170,135,190,155])add_block('built-in/To Workspace',[sys,'/','To Workspace2'])set_param([sys,'/','To Workspace2'],...		'mat-name','xout',...		'position',[260,17,310,33])add_block('built-in/To Workspace',[sys,'/','To Workspace4'])set_param([sys,'/','To Workspace4'],...		'mat-name','x1out',...		'position',[620,12,670,28])add_block('built-in/S-Function',[sys,'/',['''ct1_c1'',0.1_']])set_param([sys,'/',['''ct1_c1'',0.1_']],...		'function name','fuzzy11',...		'parameters','''ct1_c1'',0.1',...		'position',[530,48,610,72])add_block('built-in/Integrator',[sys,'/','Integrator1'])set_param([sys,'/','Integrator1'],...		'position',[450,50,470,70])add_block('built-in/Step Fcn',[sys,'/','Step Fcn1'])set_param([sys,'/','Step Fcn1'],...		'Time','0',...		'position',[390,50,410,70])add_block('built-in/Note',[sys,'/',['ctest1_s . Test model for a fuzzy-controller implementation with the toolbox.',13,'O.Wolkenhauer 29th April 1994',13,'Revised 23 Nov 94 for SIMULINK 1.3 : instead fuzzy11.m  and fuzzy21.m faster NEUROFUZ.M']])set_param([sys,'/',['ctest1_s . Test model for a fuzzy-controller implementation with the toolbox.',13,'O.Wolkenhauer 29th April 1994',13,'Revised 23 Nov 94 for SIMULINK 1.3 : instead fuzzy11.m  and fuzzy21.m faster NEUROFUZ.M']],...		'position',[395,255,400,260])add_block('built-in/Note',[sys,'/',['Run simulation from 0 to 1. Execute from workspace: plot(t,xout,t,yout) and plot(t,x1out,t,y1out)',13,'Changing the controller file ct1_c1.m shows the principle.',13,'In this example the controller is a gain of 1, the input is delayed for ONE sample period.']])set_param([sys,'/',['Run simulation from 0 to 1. Execute from workspace: plot(t,xout,t,yout) and plot(t,x1out,t,y1out)',13,'Changing the controller file ct1_c1.m shows the principle.',13,'In this example the controller is a gain of 1, the input is delayed for ONE sample period.']],...		'position',[400,190,405,195])add_block('built-in/To Workspace',[sys,'/','To Workspace3'])set_param([sys,'/','To Workspace3'],...		'mat-name','y1out',...		'position',[700,52,750,68])add_block('built-in/To Workspace',[sys,'/','To Workspace1'])set_param([sys,'/','To Workspace1'],...		'mat-name','yout',...		'position',[280,57,330,73])add_line(sys,[55,65;85,65])add_line(sys,[115,65;165,65])add_line(sys,[245,65;275,65])add_line(sys,[195,145;260,145])add_line(sys,[135,65;135,25;255,25])add_line(sys,[415,60;445,60])add_line(sys,[475,60;525,60])add_line(sys,[615,60;695,60])add_line(sys,[495,60;495,20;615,20])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);	endelse	drawnow % Flash up the model and execute load callbackend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?