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

📄 example7.m

📁 自适应控制的一些MATLAB例子
💻 M
📖 第 1 页 / 共 2 页
字号:
function [ret,x0,str,ts,xts]=example7(t,x,u,flag);%EXAMPLE7	is the M-file description of the SIMULINK system named EXAMPLE7.%	The block-diagram can be displayed by typing: EXAMPLE7.%%	SYS=EXAMPLE7(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 EXAMPLE7 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 EXAMPLE7 with a FLAG of zero:%	[SIZES]=EXAMPLE7([],[],[],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',[5,58,704,519])     open_system(sys)end;set_param(sys,'algorithm',     'RK-45')set_param(sys,'Start time',    '0.0')set_param(sys,'Stop time',     '50')set_param(sys,'Min step size', '0.001')set_param(sys,'Max step size', '10')set_param(sys,'Relative error','1e-3')set_param(sys,'Return vars',   '')set_param(sys,'AssignWideVectorLines','on');add_block('built-in/Constant',[sys,'/','mu'])set_param([sys,'/','mu'],...		'Value','0.2',...		'position',[20,129,50,161])%     Subsystem  'Text'.new_system([sys,'/','Text'])set_param([sys,'/','Text'],'Location',[181,87,640,471])add_block('built-in/Note',[sys,'/',['Text/3) the normalization parameter in the Adaptation//Normalizaton',13,'block ']])set_param([sys,'/',['Text/3) the normalization parameter in the Adaptation//Normalizaton',13,'block ']],...		'position',[220,260,225,265])add_block('built-in/Note',[sys,'/',['Text/2) the switching_sigma in the Adaptation//Modification',13,'block']])set_param([sys,'/',['Text/2) the switching_sigma in the Adaptation//Modification',13,'block']],...		'position',[190,220,195,225])add_block('built-in/Note',[sys,'/','Text/1) the adaptive gain in the Adaptation block'])set_param([sys,'/','Text/1) the adaptive gain in the Adaptation block'],...		'position',[155,180,160,185])add_block('built-in/Note',[sys,'/',['Text/To see how the parameters in the adaptive controller',13,'affect the system performance, one can change ']])set_param([sys,'/',['Text/To see how the parameters in the adaptive controller',13,'affect the system performance, one can change ']],...		'position',[195,130,200,135])add_block('built-in/Note',[sys,'/',['Text/To see the effects of unmodeled dynamics on the',13,'adaptive control performance, change mu in the ',13,'contant block marked with mu.',13,' ']])set_param([sys,'/',['Text/To see the effects of unmodeled dynamics on the',13,'adaptive control performance, change mu in the ',13,'contant block marked with mu.',13,' ']],...		'position',[190,75,195,80])add_block('built-in/Note',[sys,'/',['Text/This program simulates the robust model reference',13,'adaptive control scheme discussed in Example 9.3.2.',13,'Please refer to Chapter 9 for more details of the ',13,'problem and algorithm']])set_param([sys,'/',['Text/This program simulates the robust model reference',13,'adaptive control scheme discussed in Example 9.3.2.',13,'Please refer to Chapter 9 for more details of the ',13,'problem and algorithm']],...		'position',[190,0,195,5])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',[435,302,575,386])add_block('built-in/To Workspace',[sys,'/','To Workspace'])set_param([sys,'/','To Workspace'],...		'mat-name','yout',...		'position',[550,168,605,192])add_block('built-in/Mux',[sys,'/','Mux'])set_param([sys,'/','Mux'],...		'inputs','3',...		'position',[480,164,510,196])add_block('built-in/Clock',[sys,'/','Clock'])set_param([sys,'/','Clock'],...		'orientation',1,...		'position',[455,130,475,150])add_block('built-in/Scope',[sys,'/','y'])set_param([sys,'/','y'],...		'Vgain','1.000000',...		'Hgain','50.000000',...		'Vmax','2.000000',...		'Hmax','100.000000',...		'Window',[864,440,1186,820],...		'position',[270,65,305,105])%     Subsystem  'Controller'.new_system([sys,'/','Controller'])set_param([sys,'/','Controller'],'Location',[119,140,486,365])add_block('built-in/Inport',[sys,'/','Controller/y'])set_param([sys,'/','Controller/y'],...		'position',[35,27,60,53])add_block('built-in/Outport',[sys,'/','Controller/u'])set_param([sys,'/','Controller/u'],...		'position',[300,62,325,88])add_block('built-in/Gain',[sys,'/','Controller/Gain'])set_param([sys,'/','Controller/Gain'],...		'Gain','-1',...		'position',[225,59,260,91])add_block('built-in/Product',[sys,'/','Controller/theta*y'])set_param([sys,'/','Controller/theta*y'],...		'position',[130,57,175,88])add_block('built-in/Inport',[sys,'/','Controller/theta'])set_param([sys,'/','Controller/theta'],...		'Port','2',...		'position',[35,92,60,118])add_line([sys,'/','Controller'],[180,75;220,75])add_line([sys,'/','Controller'],[265,75;295,75])add_line([sys,'/','Controller'],[65,40;105,40;105,65;125,65])add_line([sys,'/','Controller'],[65,105;105,105;105,80;125,80])set_param([sys,'/','Controller'],...		'Mask Display','Controller\nu=-theta*y')%     Finished composite block 'Controller'.set_param([sys,'/','Controller'],...		'orientation',2,...		'Drop Shadow',4,...		'position',[130,196,220,254])%     Subsystem  'Adaptive Law'.new_system([sys,'/','Adaptive Law'])set_param([sys,'/','Adaptive Law'],'Location',[47,58,728,479])add_block('built-in/Product',[sys,'/','Adaptive Law/Product1'])set_param([sys,'/','Adaptive Law/Product1'],...		'inputs','3',...		'position',[305,127,330,163])add_block('built-in/Sum',[sys,'/','Adaptive Law/Sum2'])set_param([sys,'/','Adaptive Law/Sum2'],...		'inputs','-+',...		'position',[355,122,380,153])%     Subsystem  'Adaptive Law/Switching_sigma'.new_system([sys,'/','Adaptive Law/Switching_sigma'])set_param([sys,'/','Adaptive Law/Switching_sigma'],'Location',[54,130,506,460])add_block('built-in/Switch',[sys,'/','Adaptive Law/Switching_sigma/switching_sigma'])set_param([sys,'/','Adaptive Law/Switching_sigma/switching_sigma'],...		'position',[205,59,245,101])add_block('built-in/Inport',[sys,'/','Adaptive Law/Switching_sigma/theta'])set_param([sys,'/','Adaptive Law/Switching_sigma/theta'],...		'position',[0,64,30,96])add_block('built-in/Fcn',[sys,'/','Adaptive Law/Switching_sigma/theta_norm'])set_param([sys,'/','Adaptive Law/Switching_sigma/theta_norm'],...		'Expr','25-u(1)*u(1)',...		'position',[75,67,120,93])add_block('built-in/Constant',[sys,'/','Adaptive Law/Switching_sigma/no_modification'])set_param([sys,'/','Adaptive Law/Switching_sigma/no_modification'],...		'Value','0',...		'position',[80,9,110,41])add_block('built-in/Fcn',[sys,'/','Adaptive Law/Switching_sigma/sigma_s'])set_param([sys,'/','Adaptive Law/Switching_sigma/sigma_s'],...		'Expr','0.2*(u(1)/5-1)',...		'position',[75,136,120,164])add_block('built-in/Outport',[sys,'/','Adaptive Law/Switching_sigma/Modification'])set_param([sys,'/','Adaptive Law/Switching_sigma/Modification'],...		'position',[390,74,420,106])add_block('built-in/Product',[sys,'/','Adaptive Law/Switching_sigma/Product2'])set_param([sys,'/','Adaptive Law/Switching_sigma/Product2'],...		'position',[310,72,340,108])add_line([sys,'/','Adaptive Law/Switching_sigma'],[250,80;305,80])add_line([sys,'/','Adaptive Law/Switching_sigma'],[125,80;200,80])add_line([sys,'/','Adaptive Law/Switching_sigma'],[345,90;385,90])add_line([sys,'/','Adaptive Law/Switching_sigma'],[35,80;70,80])add_line([sys,'/','Adaptive Law/Switching_sigma'],[115,25;170,25;170,65;200,65])add_line([sys,'/','Adaptive Law/Switching_sigma'],[125,150;170,150;170,95;200,95])add_line([sys,'/','Adaptive Law/Switching_sigma'],[50,80;50,150;70,150])add_line([sys,'/','Adaptive Law/Switching_sigma'],[50,150;50,185;270,185;270,100;305,100])set_param([sys,'/','Adaptive Law/Switching_sigma'],...		'Mask Display','Modification')%     Finished composite block 'Adaptive Law/Switching_sigma'.set_param([sys,'/','Adaptive Law/Switching_sigma'],...		'orientation',2,...		'Drop Shadow',4,...		'position',[390,35,490,95])add_block('built-in/Inport',[sys,'/','Adaptive Law/y'])set_param([sys,'/','Adaptive Law/y'],...		'position',[20,87,45,113])%     Subsystem  'Adaptive Law/Normalization'.new_system([sys,'/','Adaptive Law/Normalization'])set_param([sys,'/','Adaptive Law/Normalization'],'Location',[91,142,551,356])add_block('built-in/Inport',[sys,'/','Adaptive Law/Normalization/y'])set_param([sys,'/','Adaptive Law/Normalization/y'],...		'position',[0,46,25,74])add_block('built-in/Inport',[sys,'/','Adaptive Law/Normalization/u'])set_param([sys,'/','Adaptive Law/Normalization/u'],...		'Port','2',...		'position',[0,111,25,139])add_block('built-in/Mux',[sys,'/','Adaptive Law/Normalization/Mux'])set_param([sys,'/','Adaptive Law/Normalization/Mux'],...		'inputs','2',...		'position',[60,81,90,114])add_block('built-in/Integrator',[sys,'/','Adaptive Law/Normalization/Integrator1'])set_param([sys,'/','Adaptive Law/Normalization/Integrator1'],...		'position',[270,92,295,128])add_block('built-in/Outport',[sys,'/','Adaptive Law/Normalization/1//m'])set_param([sys,'/','Adaptive Law/Normalization/1//m'],...		'position',[420,96,445,124])add_block('built-in/Fcn',[sys,'/','Adaptive Law/Normalization/Fcn1'])set_param([sys,'/','Adaptive Law/Normalization/Fcn1'],...		'Expr','1/(1+u(1))',...		'position',[340,97,395,123])add_block('built-in/Sum',[sys,'/','Adaptive Law/Normalization/Sum2'])set_param([sys,'/','Adaptive Law/Normalization/Sum2'],...		'inputs','+-',...		'position',[210,92,235,128])add_block('built-in/Fcn',[sys,'/','Adaptive Law/Normalization/u*u+y*y'])

⌨️ 快捷键说明

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