⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample2.m

📁 模糊神经网络采用matlab编程 o install NEFCON follow these steps: 1. Unpack the tar file NEFCON.TAR into your MA
💻 M
字号:
function [ret,x0,str,ts,xts]=sample2(t,x,u,flag);
%SAMPLE2	is the M-file description of the SIMULINK system named SAMPLE2.
%	The block-diagram can be displayed by typing: SAMPLE2.
%
%	SYS=SAMPLE2(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 SAMPLE2 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 SAMPLE2 with a FLAG of zero:
%	[SIZES]=SAMPLE2([],[],[],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',[100,103,655,315])
     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.01')
set_param(sys,'Max step size', '0.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   't')

add_block('built-in/Step Fcn',[sys,'/','Step Fcn'])
set_param([sys,'/','Step Fcn'],...
		'position',[20,75,40,95])

add_block('built-in/Sum',[sys,'/','error'])
set_param([sys,'/','error'],...
		'inputs','+-',...
		'position',[125,77,140,113])

add_block('built-in/Transfer Fcn',[sys,'/','pt2'])
set_param([sys,'/','pt2'],...
		'Denominator','[0.02 0.16 1]',...
		'position',[260,78,375,112])


%     Subsystem  'PID Controller'.

new_system([sys,'/','PID Controller'])
set_param([sys,'/','PID Controller'],'Location',[0,0,362,244])

add_block('built-in/Inport',[sys,'/','PID Controller/In_1'])
set_param([sys,'/','PID Controller/In_1'],...
		'position',[25,65,45,85])

add_block('built-in/Outport',[sys,'/','PID Controller/Out_1'])
set_param([sys,'/','PID Controller/Out_1'],...
		'position',[290,65,310,85])

add_block('built-in/Derivative',[sys,'/','PID Controller/Derivative'])
set_param([sys,'/','PID Controller/Derivative'],...
		'position',[150,128,190,152])

add_block('built-in/Transfer Fcn',[sys,'/','PID Controller/Integral'])
set_param([sys,'/','PID Controller/Integral'],...
		'Numerator','[I]',...
		'Denominator','[1 0]',...
		'position',[110,57,145,93])

add_block('built-in/Gain',[sys,'/','PID Controller/Proportional'])
set_param([sys,'/','PID Controller/Proportional'],...
		'Gain','P',...
		'position',[120,13,140,37])

add_block('built-in/Gain',[sys,'/','PID Controller/D'])
set_param([sys,'/','PID Controller/D'],...
		'Gain','D',...
		'position',[95,129,115,151])

add_block('built-in/Sum',[sys,'/','PID Controller/Sum'])
set_param([sys,'/','PID Controller/Sum'],...
		'inputs','+++',...
		'position',[245,57,265,93])
add_line([sys,'/','PID Controller'],[145,25;210,25;210,65;240,65])
add_line([sys,'/','PID Controller'],[150,75;240,75])
add_line([sys,'/','PID Controller'],[195,140;215,140;215,85;240,85])
add_line([sys,'/','PID Controller'],[50,75;105,75])
add_line([sys,'/','PID Controller'],[80,75;80,25;115,25])
add_line([sys,'/','PID Controller'],[65,75;65,140;90,140])
add_line([sys,'/','PID Controller'],[270,75;285,75])
add_line([sys,'/','PID Controller'],[120,140;145,140])
set_param([sys,'/','PID Controller'],...
		'Mask Display','PID',...
		'Mask Type','PID Controller',...
		'Mask Dialogue','Enter expressions for proportional, integral, and derivitive terms.|Proportional:|Integral|Derivitive:')
set_param([sys,'/','PID Controller'],...
		'Mask Translate','P=@1; I=@2; D=@3;')
set_param([sys,'/','PID Controller'],...
		'Mask Help','This block implements a PID controller where paramaters are entered for the Proportional, Integral and Derivitive terms. Unmask this block to see how it works. The derivative term is implemented using a true derivative block.')
set_param([sys,'/','PID Controller'],...
		'Mask Entries','P\/I\/D\/')


%     Finished composite block 'PID Controller'.

set_param([sys,'/','PID Controller'],...
		'position',[180,79,220,111])

add_block('built-in/Outport',[sys,'/','Outport1'])
set_param([sys,'/','Outport1'],...
		'hide name',0,...
		'Drop Shadow',4,...
		'Mask Display','plot(t,y); 1',...
		'Mask Type','Optimization outport',...
		'Mask Dialogue','eval(''optblock'')')
set_param([sys,'/','Outport1'],...
		'Mask Translate','t=1:10; y=[-.5 1.5 .6 1.3 .8 1.1 .95 1.02 .99 1];',...
		'position',[485,68,540,122])

add_block('built-in/To Workspace',[sys,'/','To Workspace7'])
set_param([sys,'/','To Workspace7'],...
		'hide name',0,...
		'mat-name','u',...
		'buffer','3000',...
		'position',[135,32,185,48])
add_line(sys,[45,85;120,85])
add_line(sys,[380,95;480,95])
add_line(sys,[430,95;430,195;110,195;120,105])
add_line(sys,[145,95;175,95])
add_line(sys,[225,95;255,95])
add_line(sys,[110,85;110,40;130,40])

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

⌨️ 快捷键说明

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