📄 parmest.m
字号:
function [ret,x0,str,ts,xts]=parmest(t,x,u,flag);
%PARMEST is the M-file description of the SIMULINK system named PARMEST.
% The block-diagram can be displayed by typing: PARMEST.
%
% SYS=PARMEST(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 PARMEST 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 PARMEST with a FLAG of zero:
% [SIZES]=PARMEST([],[],[],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.
% 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',[12,64,567,476])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '10000')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '5')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Constant',[sys,'/','Parameter'])
set_param([sys,'/','Parameter'],...
'Value','10',...
'position',[45,96,75,124])
add_block('built-in/Signal Generator',[sys,'/',['Parameter',13,'Variation']])
set_param([sys,'/',['Parameter',13,'Variation']],...
'Peak','4.000000',...
'Peak Range','20.000000',...
'Freq','0.100000',...
'Freq Range','0.500000',...
'Wave','Sqr',...
'Units','Rads',...
'position',[35,23,80,57])
add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
'hide name',0,...
'position',[110,65,125,85])
add_block('built-in/Scope',[sys,'/','System output'])
set_param([sys,'/','System output'],...
'Vgain','10.000000',...
'Hgain','150.000000',...
'Vmax','20.000000',...
'Hmax','300.000000',...
'Window',[853,132,1086,263],...
'position',[470,73,495,107])
add_block('built-in/Scope',[sys,'/','Error'])
set_param([sys,'/','Error'],...
'Vgain','5.000000',...
'Hgain','150.000000',...
'Vmax','10.000000',...
'Hmax','300.000000',...
'Window',[573,151,829,282])
open_system([sys,'/','Error'])
set_param([sys,'/','Error'],...
'position',[505,162,530,198])
add_block('built-in/Note',[sys,'/','System under test'])
set_param([sys,'/','System under test'],...
'position',[325,45,330,50])
add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
'hide name',0,...
'inputs','+-',...
'position',[255,80,270,100])
add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn'])
set_param([sys,'/','Transfer Fcn'],...
'hide name',0,...
'Numerator','[2,1]',...
'Denominator','[2,5,3]',...
'position',[285,70,365,110])
add_block('built-in/Signal Generator',[sys,'/','excitation'])
set_param([sys,'/','excitation'],...
'Peak','1.940000',...
'Peak Range','2.000000',...
'Freq','2.000000',...
'Freq Range','2.000000',...
'Wave','Saw',...
'Units','Rads',...
'position',[75,158,120,192])
add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
'hide name',0,...
'inputs','+-',...
'position',[435,170,450,190])
add_block('built-in/Scope',[sys,'/','Estimate'])
set_param([sys,'/','Estimate'],...
'Vgain','15.000000',...
'Hgain','150.000000',...
'Vmax','30.000000',...
'Hmax','300.000000',...
'Window',[574,416,831,543])
open_system([sys,'/','Estimate'])
set_param([sys,'/','Estimate'],...
'position',[390,252,415,288])
add_block('built-in/Note',[sys,'/',['Parameter Estimation',13,'(Double click on the "?" for more info)']])
set_param([sys,'/',['Parameter Estimation',13,'(Double click on the "?" for more info)']],...
'position',[196,330,201,335])
add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn1'])
set_param([sys,'/','Transfer Fcn1'],...
'hide name',0,...
'Numerator','[2,1]',...
'Denominator','[2,5,3]',...
'position',[305,165,390,205])
add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
'hide name',0,...
'inputs','+-',...
'position',[270,175,285,195])
add_block('built-in/Product',[sys,'/','Product'])
set_param([sys,'/','Product'],...
'hide name',0,...
'position',[235,170,250,190])
add_block('built-in/Product',[sys,'/',['Parameter',13,'being',13,'estimated']])
set_param([sys,'/',['Parameter',13,'being',13,'estimated']],...
'position',[180,66,200,99])
add_block('built-in/Note',[sys,'/',['estimated',13,'parameter']])
set_param([sys,'/',['estimated',13,'parameter']],...
'position',[325,235,330,240])
add_block('built-in/Note',[sys,'/',['error',13,'signal']])
set_param([sys,'/',['error',13,'signal']],...
'position',[470,145,475,150])
add_block('built-in/Product',[sys,'/','Product1'])
set_param([sys,'/','Product1'],...
'hide name',0,...
'position',[160,260,175,280])
add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn2'])
set_param([sys,'/','Transfer Fcn2'],...
'hide name',0,...
'Denominator','[1,0]',...
'position',[190,250,215,290])
add_block('built-in/Note',[sys,'/',['To start and stop the simulation, use the "Start//Stop"',13,'selection in the "Simulation" pull-down menu']])
set_param([sys,'/',['To start and stop the simulation, use the "Start//Stop"',13,'selection in the "Simulation" pull-down menu']],...
'position',[194,370,199,375])
% Subsystem 'More Info'.
new_system([sys,'/','More Info'])
set_param([sys,'/','More Info'],'Location',[50,150,431,359])
add_block('built-in/Note',[sys,'/',['More Info/The changing value of the gain applied in the ',13,'Product block "Parameter being estimated" is ',13,'the quantity being estimated.']])
set_param([sys,'/',['More Info/The changing value of the gain applied in the ',13,'Product block "Parameter being estimated" is ',13,'the quantity being estimated.']],...
'position',[185,60,190,65])
add_block('built-in/Note',[sys,'/',['More Info/This system estimates a single scalar parameter.',13,'Open the scopes and run the simulation.']])
set_param([sys,'/',['More Info/This system estimates a single scalar parameter.',13,'Open the scopes and run the simulation.']],...
'position',[180,15,185,20])
add_block('built-in/Note',[sys,'/',['More Info/Watch the system estimate and error respond as the',13,'gain parameter changes during the simulation.']])
set_param([sys,'/',['More Info/Watch the system estimate and error respond as the',13,'gain parameter changes during the simulation.']],...
'position',[187,125,192,130])
set_param([sys,'/','More Info'],...
'Mask Display','?')
% Finished composite block 'More Info'.
set_param([sys,'/','More Info'],...
'hide name',0,...
'Drop Shadow',4,...
'position',[340,335,367,360])
add_line(sys,[395,185;430,185])
add_line(sys,[255,180;265,180])
add_line(sys,[290,185;300,185])
add_line(sys,[395,185;395,220;255,220;265,190])
add_line(sys,[455,180;500,180])
add_line(sys,[180,270;185,270])
add_line(sys,[220,270;385,270])
add_line(sys,[125,175;135,175;135,90;175,90])
add_line(sys,[370,90;465,90])
add_line(sys,[220,270;240,270;240,235;220,235;230,185])
add_line(sys,[370,90;410,90;410,175;430,175])
add_line(sys,[455,180;470,180;470,310;135,310;135,275;155,275])
add_line(sys,[205,85;250,85])
add_line(sys,[275,90;280,90])
add_line(sys,[370,90;390,90;390,140;240,140;250,95])
add_line(sys,[125,175;135,175;135,265;155,265])
add_line(sys,[135,175;230,175])
add_line(sys,[85,40;95,40;105,70])
add_line(sys,[80,110;95,110;105,80])
add_line(sys,[130,75;175,75])
% 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
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -