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

📄 sample1a.m

📁 模糊神经网络采用matlab编程 o install NEFCON follow these steps: 1. Unpack the tar file NEFCON.TAR into your MA
💻 M
📖 第 1 页 / 共 2 页
字号:
function [ret,x0,str,ts,xts]=sample1a(t,x,u,flag);
%SAMPLE1A	is the M-file description of the SIMULINK system named SAMPLE1A.
%	The block-diagram can be displayed by typing: SAMPLE1A.
%
%	SYS=SAMPLE1A(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 SAMPLE1A 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 SAMPLE1A with a FLAG of zero:
%	[SIZES]=SAMPLE1A([],[],[],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',[14,42,689,378])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '200')
set_param(sys,'Min step size', '0.5')
set_param(sys,'Max step size', '0.5')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Sum',[sys,'/','error'])
set_param([sys,'/','error'],...
		'inputs','+-',...
		'position',[125,115,145,135])


%     Subsystem  'Nefcon-SigGen'.

new_system([sys,'/','Nefcon-SigGen'])
set_param([sys,'/','Nefcon-SigGen'],'Location',[461,444,1004,748])

add_block('built-in/Signal Generator',[sys,'/',['Nefcon-SigGen/Signal Gen.',13,'f_rad=2*pi*f_Hz']])
set_param([sys,'/',['Nefcon-SigGen/Signal Gen.',13,'f_rad=2*pi*f_Hz']],...
		'Peak','0.500000',...
		'Peak Range','5.000000',...
		'Freq','0.050000',...
		'Freq Range','0.500000',...
		'Wave','Sqr',...
		'Units','Rads')
set_param([sys,'/',['Nefcon-SigGen/Signal Gen.',13,'f_rad=2*pi*f_Hz']],...
		'position',[70,59,110,81])

add_block('built-in/Constant',[sys,'/','Nefcon-SigGen/Constant'])
set_param([sys,'/','Nefcon-SigGen/Constant'],...
		'position',[155,125,175,145])

add_block('built-in/Gain',[sys,'/','Nefcon-SigGen/Gain1'])
set_param([sys,'/','Nefcon-SigGen/Gain1'],...
		'position',[355,119,410,151])

add_block('built-in/Sum',[sys,'/','Nefcon-SigGen/Sum'])
set_param([sys,'/','Nefcon-SigGen/Sum'],...
		'inputs','+++',...
		'position',[290,38,320,232])

add_block('built-in/Outport',[sys,'/','Nefcon-SigGen/out_1'])
set_param([sys,'/','Nefcon-SigGen/out_1'],...
		'position',[440,125,460,145])

add_block('built-in/Constant',[sys,'/','Nefcon-SigGen/Constant1'])
set_param([sys,'/','Nefcon-SigGen/Constant1'],...
		'Value','0',...
		'position',[150,240,170,260])

add_block('built-in/Switch',[sys,'/','Nefcon-SigGen/Switch'])
set_param([sys,'/','Nefcon-SigGen/Switch'],...
		'Threshold','0.5',...
		'position',[200,167,225,233])

add_block('built-in/Gain',[sys,'/','Nefcon-SigGen/Gain'])
set_param([sys,'/','Nefcon-SigGen/Gain'],...
		'Gain','0.4',...
		'position',[90,164,145,196])

add_block('built-in/Signal Generator',[sys,'/','Nefcon-SigGen/Rauschen'])
set_param([sys,'/','Nefcon-SigGen/Rauschen'],...
		'Peak','1.000000',...
		'Peak Range','5.000000',...
		'Freq','1.000000',...
		'Freq Range','5.000000',...
		'Wave','Rnd',...
		'Units','Rads',...
		'position',[25,169,65,191])


%     Subsystem  'Nefcon-SigGen/Get Signal'.

new_system([sys,'/','Nefcon-SigGen/Get Signal'])
set_param([sys,'/','Nefcon-SigGen/Get Signal'],'Location',[200,498,478,742])

add_block('built-in/S-Function',[sys,'/','Nefcon-SigGen/Get Signal/S-Function1'])
set_param([sys,'/','Nefcon-SigGen/Get Signal/S-Function1'],...
		'function name','getsig',...
		'parameters','width,name',...
		'position',[65,48,115,72])

add_block('built-in/Outport',[sys,'/','Nefcon-SigGen/Get Signal/out_1'])
set_param([sys,'/','Nefcon-SigGen/Get Signal/out_1'],...
		'position',[125,50,145,70])
add_line([sys,'/','Nefcon-SigGen/Get Signal'],[120,60;120,60])
set_param([sys,'/','Nefcon-SigGen/Get Signal'],...
		'Mask Display','GETSIG',...
		'Mask Type','GEt Signal',...
		'Mask Dialogue','Put a signal into the MATLAB workspace.  Specify the signal width and name. | Signal Width: | Name (in quotes):')
set_param([sys,'/','Nefcon-SigGen/Get Signal'],...
		'Mask Translate','width=@1;name=@2;')
set_param([sys,'/','Nefcon-SigGen/Get Signal'],...
		'Mask Help','Get signal from the MATLAB workspace. To be used in conjunction with PUTSIG. Names must be entered as strings.  The code for this block is getsig.c')
set_param([sys,'/','Nefcon-SigGen/Get Signal'],...
		'Mask Entries','1\/''NEFCON_NOISE''\/')


%     Finished composite block 'Nefcon-SigGen/Get Signal'.

set_param([sys,'/','Nefcon-SigGen/Get Signal'],...
		'position',[35,210,95,250])
add_line([sys,'/','Nefcon-SigGen'],[180,135;285,135])
add_line([sys,'/','Nefcon-SigGen'],[70,180;85,180])
add_line([sys,'/','Nefcon-SigGen'],[115,70;285,70])
add_line([sys,'/','Nefcon-SigGen'],[415,135;435,135])
add_line([sys,'/','Nefcon-SigGen'],[325,135;350,135])
add_line([sys,'/','Nefcon-SigGen'],[230,200;285,200])
add_line([sys,'/','Nefcon-SigGen'],[150,180;195,180])
add_line([sys,'/','Nefcon-SigGen'],[175,250;180,250;180,220;195,220])
add_line([sys,'/','Nefcon-SigGen'],[100,230;140,230;140,200;195,200])
set_param([sys,'/','Nefcon-SigGen'],...
		'Mask Display','NEFCON\nSigGen')


%     Finished composite block 'Nefcon-SigGen'.

set_param([sys,'/','Nefcon-SigGen'],...
		'BackGround',2,...
		'hide name',0,...
		'position',[20,95,90,145])

add_block('built-in/Scope',[sys,'/','Scope2'])
set_param([sys,'/','Scope2'],...
		'orientation',2,...
		'Vgain','2.000000',...
		'Hgain','20.000000',...
		'Vmax','4.000000',...
		'Hmax','40.000000',...
		'Window',[207,553,469,687],...
		'position',[400,185,430,215])


%     Subsystem  'tank 2'.

new_system([sys,'/','tank 2'])
set_param([sys,'/','tank 2'],'Location',[109,460,655,768])

add_block('built-in/Gain',[sys,'/','tank 2/1//Height'])
set_param([sys,'/','tank 2/1//Height'],...
		'Gain','1/ht',...
		'position',[185,77,235,133])

add_block('built-in/Outport',[sys,'/',['tank 2/overflow',13,'flag']])
set_param([sys,'/',['tank 2/overflow',13,'flag']],...
		'Port','3',...
		'position',[495,30,515,50])

add_block('built-in/Outport',[sys,'/',['tank 2/water',13,'level']])
set_param([sys,'/',['tank 2/water',13,'level']],...
		'position',[495,100,515,120])

add_block('built-in/Gain',[sys,'/','tank 2/1//area'])
set_param([sys,'/','tank 2/1//area'],...
		'Gain','1/area',...
		'position',[220,167,270,223])

add_block('built-in/Gain',[sys,'/','tank 2/outletArea'])
set_param([sys,'/','tank 2/outletArea'],...
		'Gain','outletArea',...
		'position',[410,167,460,223])

add_block('built-in/Fcn',[sys,'/','tank 2/sqrt(2gh)'])
set_param([sys,'/','tank 2/sqrt(2gh)'],...
		'Expr','sqrt(2*9.8*u)',...
		'position',[300,171,390,219])


%     Subsystem  ['tank 2/tank',13,'volume'].

new_system([sys,'/',['tank 2/tank',13,'volume']])
set_param([sys,'/',['tank 2/tank',13,'volume']],'Location',[0,0,791,233])

add_block('built-in/Saturation',[sys,'/',['tank 2/tank',13,'volume/Saturation']])
set_param([sys,'/',['tank 2/tank',13,'volume/Saturation']],...
		'Lower Limit','lb',...
		'Upper Limit','ub',...
		'position',[630,121,675,149])

add_block('built-in/Fcn',[sys,'/',['tank 2/tank',13,'volume/Fcn']])
set_param([sys,'/',['tank 2/tank',13,'volume/Fcn']],...
		'Expr','u[2]*((((u[1]>lb)+(u[2]>=0))>0) * (((u[1]<ub)+(u[2]<=0))>0))',...
		'position',[150,116,520,154])

add_block('built-in/Inport',[sys,'/',['tank 2/tank',13,'volume/In_1']])
set_param([sys,'/',['tank 2/tank',13,'volume/In_1']],...
		'position',[20,130,40,150])

add_block('built-in/Outport',[sys,'/',['tank 2/tank',13,'volume/Out_1']])
set_param([sys,'/',['tank 2/tank',13,'volume/Out_1']],...
		'position',[720,125,740,145])

add_block('built-in/Integrator',[sys,'/',['tank 2/tank',13,'volume/Integrator']])
set_param([sys,'/',['tank 2/tank',13,'volume/Integrator']],...
		'Initial','xi',...
		'position',[540,126,585,144])

add_block('built-in/Mux',[sys,'/',['tank 2/tank',13,'volume/Mux']])
set_param([sys,'/',['tank 2/tank',13,'volume/Mux']],...
		'inputs','2',...
		'position',[85,116,115,149])
add_line([sys,'/',['tank 2/tank',13,'volume']],[680,135;715,135])
add_line([sys,'/',['tank 2/tank',13,'volume']],[45,140;80,140])
add_line([sys,'/',['tank 2/tank',13,'volume']],[120,135;145,135])
add_line([sys,'/',['tank 2/tank',13,'volume']],[525,135;535,135])
add_line([sys,'/',['tank 2/tank',13,'volume']],[590,135;625,135])
add_line([sys,'/',['tank 2/tank',13,'volume']],[600,135;600,35;55,35;55,125;80,125])
set_param([sys,'/',['tank 2/tank',13,'volume']],...
		'Mask Display','plot(-1,-0.2,3.5,1.2,[0.05,1,2,2.9],[0,0,1,1]); 1/s    ',...
		'Mask Type','Limited integrator.')
set_param([sys,'/',['tank 2/tank',13,'volume']],...
		'Mask Dialogue','Limited integrator|Lower bound:|Upper bound:|Initial condition',...
		'Mask Translate','lb = @1; ub = @2; xi = @3;')
set_param([sys,'/',['tank 2/tank',13,'volume']],...
		'Mask Help','Implements a limited integrator with \nan expression of the form:\n\nif(x<=lb and u<0) or (x>=ub and u>0)\n\txdot=0\nelse\n\txdot=u.')
set_param([sys,'/',['tank 2/tank',13,'volume']],...
		'Mask Entries','0\/ht * area\/initialHt * area\/')


%     Finished composite block ['tank 2/tank',13,'volume'].

set_param([sys,'/',['tank 2/tank',13,'volume']],...
		'position',[150,174,200,216])

add_block('built-in/Sum',[sys,'/','tank 2/sum'])
set_param([sys,'/','tank 2/sum'],...
		'inputs','+-',...
		'position',[105,175,125,210])

add_block('built-in/Inport',[sys,'/',['tank 2/flow',13,'in']])

⌨️ 快捷键说明

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