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

📄 example5.m

📁 自适应控制的一些MATLAB例子
💻 M
📖 第 1 页 / 共 2 页
字号:
function [ret,x0,str,ts,xts]=example5(t,x,u,flag);%EXAMPLE5	is the M-file description of the SIMULINK system named EXAMPLE5.%	The block-diagram can be displayed by typing: EXAMPLE5.%%	SYS=EXAMPLE5(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 EXAMPLE5 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 EXAMPLE5 with a FLAG of zero:%	[SIZES]=EXAMPLE5([],[],[],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',[4,58,792,599])     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.0001')set_param(sys,'Max step size', '10')set_param(sys,'Relative error','1e-3')set_param(sys,'Return vars',   '')set_param(sys,'AssignWideVectorLines','on');%     Subsystem  'Omega'.new_system([sys,'/','Omega'])set_param([sys,'/','Omega'],'Location',[89,111,608,439])add_block('built-in/Inport',[sys,'/','Omega/u'])set_param([sys,'/','Omega/u'],...		'position',[20,29,50,61])add_block('built-in/Transfer Fcn',[sys,'/','Omega/F(s)'])set_param([sys,'/','Omega/F(s)'],...		'Denominator','[1 2]',...		'position',[110,23,175,67])add_block('built-in/Inport',[sys,'/','Omega/y'])set_param([sys,'/','Omega/y'],...		'Port','2',...		'position',[20,103,50,137])add_block('built-in/Transfer Fcn',[sys,'/','Omega/F(s)_'])set_param([sys,'/','Omega/F(s)_'],...		'Denominator','[1 2]',...		'position',[110,100,175,140])add_block('built-in/Mux',[sys,'/','Omega/Mux'])set_param([sys,'/','Omega/Mux'],...		'position',[390,102,420,148])add_block('built-in/Inport',[sys,'/','Omega/r'])set_param([sys,'/','Omega/r'],...		'Port','3',...		'position',[20,197,50,233])add_block('built-in/Outport',[sys,'/','Omega/omega'])set_param([sys,'/','Omega/omega'],...		'position',[465,109,495,141])add_line([sys,'/','Omega'],[425,125;460,125])add_line([sys,'/','Omega'],[55,120;105,120])add_line([sys,'/','Omega'],[55,45;105,45])add_line([sys,'/','Omega'],[180,45;365,45;365,110;385,110])add_line([sys,'/','Omega'],[180,120;385,120])add_line([sys,'/','Omega'],[80,120;80,180;365,180;365,130;385,130])add_line([sys,'/','Omega'],[55,215;375,215;385,140])set_param([sys,'/','Omega'],...		'Mask Display','Filter\n(generates omega)')%     Finished composite block 'Omega'.set_param([sys,'/','Omega'],...		'Drop Shadow',4,...		'position',[210,181,350,249])%     Subsystem  'Text'.new_system([sys,'/','Text'])set_param([sys,'/','Text'],'Location',[58,142,488,559])add_block('built-in/Note',[sys,'/',['Text/5) The plant model. Please remember that this program',13,'is designed for a second order minimum phase plant ',13,'that has relative degree equal to 1.']])set_param([sys,'/',['Text/5) The plant model. Please remember that this program',13,'is designed for a second order minimum phase plant ',13,'that has relative degree equal to 1.']],...		'position',[200,305,205,310])add_block('built-in/Note',[sys,'/',['Text/4) The parameters in the estimator, i.e., the adaptive gains',13,'and the initial estimates']])set_param([sys,'/',['Text/4) The parameters in the estimator, i.e., the adaptive gains',13,'and the initial estimates']],...		'position',[215,260,220,265])add_block('built-in/Note',[sys,'/','Text/3) The parameters of the filter'])set_param([sys,'/','Text/3) The parameters of the filter'],...		'position',[120,225,125,230])add_block('built-in/Note',[sys,'/',['Text/2) The reference model',13,'']])set_param([sys,'/',['Text/2) The reference model',13,'']],...		'position',[100,195,105,200])add_block('built-in/Note',[sys,'/','Text/1) The excitation input r'])set_param([sys,'/','Text/1) The excitation input r'],...		'position',[100,165,105,170])add_block('built-in/Note',[sys,'/',['Text/This program simulates the model reference adaptive ',13,'control scheme discussed in Example 6.4.1. Please ',13,'refer to Example 6.4.1 on page 360 and Table 6.4.1',13,'on page 357of the textbook for details.']])set_param([sys,'/',['Text/This program simulates the model reference adaptive ',13,'control scheme discussed in Example 6.4.1. Please ',13,'refer to Example 6.4.1 on page 360 and Table 6.4.1',13,'on page 357of the textbook for details.']],...		'position',[205,0,210,5])add_block('built-in/Note',[sys,'/',['Text/You can change the following parameters in this program',13,'to see their effects on the performance of the adaptive',13,'control scheme:',13,'']])set_param([sys,'/',['Text/You can change the following parameters in this program',13,'to see their effects on the performance of the adaptive',13,'control scheme:',13,'']],...		'position',[205,85,210,90])set_param([sys,'/','Text'],...		'Mask Display','Double click here\nfor help to run\nthe simulation')%     Finished composite block 'Text'.set_param([sys,'/','Text'],...		'Drop Shadow',4,...		'position',[142,367,270,441])add_block('built-in/Transfer Fcn',[sys,'/','Plant Model'])set_param([sys,'/','Plant Model'],...		'Numerator','[1 1]',...		'Denominator','[1  3 -10]',...		'position',[530,188,600,232])add_block('built-in/To Workspace',[sys,'/','To Workspace'])set_param([sys,'/','To Workspace'],...		'mat-name','yout',...		'position',[755,430,810,460])add_block('built-in/Demux',[sys,'/','Demux'])set_param([sys,'/','Demux'],...		'position',[535,435,575,485])add_block('built-in/Clock',[sys,'/','Clock'])set_param([sys,'/','Clock'],...		'orientation',1,...		'position',[650,370,670,390])add_block('built-in/Mux',[sys,'/','Mux1'])set_param([sys,'/','Mux1'],...		'inputs','7',...		'position',[680,408,720,482])add_block('built-in/Scope',[sys,'/','Tracking Error'])set_param([sys,'/','Tracking Error'],...		'Vgain','2.000000',...		'Hgain','100.000000',...		'Vmax','4.000000',...		'Hmax','200.000000',...		'Window',[832,536,1154,916],...		'position',[755,128,795,172])add_block('built-in/Sum',[sys,'/','e1'])set_param([sys,'/','e1'],...		'inputs','-+',...		'position',[685,132,715,163])add_block('built-in/Transfer Fcn',[sys,'/','Reference Model'])set_param([sys,'/','Reference Model'],...		'Denominator','[1 1]',...		'position',[365,68,440,112])%     Subsystem  'Input r'.new_system([sys,'/','Input r'])set_param([sys,'/','Input r'],'Location',[163,146,563,413])add_block('built-in/Step Fcn',[sys,'/','Input r/Step Input'])set_param([sys,'/','Input r/Step Input'],...		'position',[60,154,95,186])add_block('built-in/Gain',[sys,'/','Input r/Gain2'])set_param([sys,'/','Input r/Gain2'],...		'Gain','0',...		'position',[150,154,180,186])add_block('built-in/Sine Wave',[sys,'/','Input r/Sine Wave'])set_param([sys,'/','Input r/Sine Wave'],...		'frequency','5.9',...		'position',[55,91,95,129])add_block('built-in/Sine Wave',[sys,'/','Input r/Sine Wave1'])set_param([sys,'/','Input r/Sine Wave1'],...		'amplitude','0.7',...		'phase','1.5',...		'position',[55,38,95,72])add_block('built-in/Outport',[sys,'/','Input r/sin wave'])set_param([sys,'/','Input r/sin wave'],...		'position',[330,97,360,123])add_block('built-in/Sum',[sys,'/','Input r/Sum'])set_param([sys,'/','Input r/Sum'],...		'inputs','+++',...		'position',[240,85,275,135])add_block('built-in/Gain',[sys,'/','Input r/Gain1'])set_param([sys,'/','Input r/Gain1'],...		'Gain','2',...		'position',[150,94,180,126])add_block('built-in/Gain',[sys,'/','Input r/Gain'])set_param([sys,'/','Input r/Gain'],...

⌨️ 快捷键说明

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