📄 h2demo1.m
字号:
function [ret,x0,str]=h2demo1(t,x,u,flag);
%H2DEMO1 is the M-file description of the SIMULINK system named H2DEMO1.
% The block-diagram can be displayed by typing: H2DEMO1.
%
% SYS=H2DEMO1(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 H2DEMO1 to return state derivitives, FLAG=2
% discrete states, FLAG=3 system outputs and FLAG=4 next sample
% time. For more information and other options see SFUNC.
%
% Calling H2DEMO1 with a FLAG of zero:
% [SIZES]=H2DEMO1([],[],[],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.
% Copyright (c) 1990-94 by The MathWorks, Inc.
% 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',[442,222,1015,615])
open_system(sys)
end;
set_param(sys,'algorithm', 'Linear')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '2000')
set_param(sys,'Min step size', '0.01')
set_param(sys,'Max step size', '0.1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
'inputs','++-',...
'position',[105,152,125,198])
% Subsystem 'More Info'.
new_system([sys,'/','More Info'])
set_param([sys,'/','More Info'],'Location',[15,105,404,220])
add_block('built-in/Note',[sys,'/',['More Info/The original open-loop plant is an unstable system. Compare',13,'regular LQG desgin to see the difference.']])
set_param([sys,'/',['More Info/The original open-loop plant is an unstable system. Compare',13,'regular LQG desgin to see the difference.']],...
'position',[191,75,192,76])
add_block('built-in/Note',[sys,'/',['More Info/This demonstration shows LQG//LTR controller design method.',13,'Robust control tool box is used in the design']])
set_param([sys,'/',['More Info/This demonstration shows LQG//LTR controller design method.',13,'Robust control tool box is used in the design']],...
'position',[192,25,193,26])
set_param([sys,'/','More Info'],...
'Mask Display','?')
% Finished composite block 'More Info'.
set_param([sys,'/','More Info'],...
'BackGround',5,...
'hide name',0,...
'Drop Shadow',4,...
'position',[810,440,837,465])
add_block('built-in/Outport',[sys,'/','Outport1'])
set_param([sys,'/','Outport1'],...
'position',[520,50,540,70])
add_block('built-in/Outport',[sys,'/','Outport2'])
set_param([sys,'/','Outport2'],...
'Port','2',...
'position',[525,90,545,110])
add_block('built-in/Outport',[sys,'/','Outport3'])
set_param([sys,'/','Outport3'],...
'Port','3',...
'position',[525,240,545,260])
add_block('built-in/Note',[sys,'/','H_2 Controller Design'])
set_param([sys,'/','H_2 Controller Design'],...
'position',[289,10,290,11])
add_block('built-in/Inport',[sys,'/','Inport'])
set_param([sys,'/','Inport'],...
'position',[35,105,55,125])
add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','1.000000',...
'Freq Range','5.000000',...
'Wave','Sqr',...
'Units','Rads',...
'position',[30,158,70,192])
add_block('built-in/State-space',[sys,'/','Controller1'])
set_param([sys,'/','Controller1'],...
'A','ae',...
'B','be',...
'C','ce',...
'D','de',...
'Mask Display','H_2 Controller',...
'Mask Type','H_2 CONTROLLER')
set_param([sys,'/','Controller1'],...
'Mask Dialogue','H_2 controller.\n(Requires Control Toolbox and RCT)|Controller Matrix A:|Controller Matrix B:|Controller Matrix C:|Controller Matrix D:',...
'Mask Translate','ae=@1; be=@2; ce=@3; de=@4;')
set_param([sys,'/','Controller1'],...
'Mask Help','H_2 controller design. Mask and unmask this block to see how it works.',...
'Mask Entries','ae\/be\/ce\/de\/',...
'position',[175,150,265,200])
add_block('built-in/Outport',[sys,'/','Outport'])
set_param([sys,'/','Outport'],...
'Port','4',...
'position',[520,140,540,160])
% Subsystem 'Plant'.
new_system([sys,'/','Plant'])
set_param([sys,'/','Plant'],'Location',[646,300,1072,521])
add_block('built-in/State-space',[sys,'/','Plant/State-space'])
set_param([sys,'/','Plant/State-space'],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Mask Display','',...
'position',[110,40,170,70])
add_block('built-in/Outport',[sys,'/','Plant/out'])
set_param([sys,'/','Plant/out'],...
'position',[380,55,400,75])
add_block('built-in/Sum',[sys,'/','Plant/Sum1'])
set_param([sys,'/','Plant/Sum1'],...
'inputs','+++',...
'position',[320,47,340,83])
add_block('built-in/Product',[sys,'/','Plant/Product'])
set_param([sys,'/','Plant/Product'],...
'position',[225,90,250,110])
add_block('built-in/Inport',[sys,'/','Plant/in'])
set_param([sys,'/','Plant/in'],...
'position',[40,45,60,65])
% Subsystem ['Plant/Multiplicative',13,'noise'].
new_system([sys,'/',['Plant/Multiplicative',13,'noise']])
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],'Location',[0,0,262,236])
add_block('built-in/Outport',[sys,'/',['Plant/Multiplicative',13,'noise/out_1']])
set_param([sys,'/',['Plant/Multiplicative',13,'noise/out_1']],...
'position',[235,70,255,90])
add_block('built-in/White Noise',[sys,'/',['Plant/Multiplicative',13,'noise/White Noise']])
set_param([sys,'/',['Plant/Multiplicative',13,'noise/White Noise']],...
'Seed','seed',...
'position',[55,70,75,90])
add_block('built-in/Discrete Transfer Fcn',[sys,'/',['Plant/Multiplicative',13,'noise/Zero Order Hold']])
set_param([sys,'/',['Plant/Multiplicative',13,'noise/Zero Order Hold']],...
'Numerator','[sqrt(Cov)]',...
'Denominator','[sqrt(Ts)]',...
'Sample time','Ts',...
'position',[140,61,205,99])
add_line([sys,'/',['Plant/Multiplicative',13,'noise']],[210,80;225,80])
add_line([sys,'/',['Plant/Multiplicative',13,'noise']],[80,80;130,80])
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],...
'Mask Display','plot(1:20,rand(1,20))',...
'Mask Type','Input Noise')
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],...
'Mask Dialogue','White noise for continuous (s-domain) systems.\nBand-limited using zero-order-hold.|Noise Variance:|Sample Time:|Seed')
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],...
'Mask Translate','Cov = @1; Ts = @2; seed = @3; r = rand(1,12)-0.5; ')
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],...
'Mask Help','Implemented using white noise into Zero Order Hold block. For faster simulation set sample time to highest value possible but in accordance with the fastest dynamics of system.')
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],...
'Mask Entries','0.1\/1\/68342\/')
% Finished composite block ['Plant/Multiplicative',13,'noise'].
set_param([sys,'/',['Plant/Multiplicative',13,'noise']],...
'position',[65,89,105,121])
% Subsystem ['Plant/Additive',13,'noise'].
new_system([sys,'/',['Plant/Additive',13,'noise']])
set_param([sys,'/',['Plant/Additive',13,'noise']],'Location',[0,0,262,236])
add_block('built-in/Outport',[sys,'/',['Plant/Additive',13,'noise/out_1']])
set_param([sys,'/',['Plant/Additive',13,'noise/out_1']],...
'position',[235,70,255,90])
add_block('built-in/White Noise',[sys,'/',['Plant/Additive',13,'noise/White Noise']])
set_param([sys,'/',['Plant/Additive',13,'noise/White Noise']],...
'Seed','seed',...
'position',[55,70,75,90])
add_block('built-in/Discrete Transfer Fcn',[sys,'/',['Plant/Additive',13,'noise/Zero Order Hold']])
set_param([sys,'/',['Plant/Additive',13,'noise/Zero Order Hold']],...
'Numerator','[sqrt(Cov)]',...
'Denominator','[sqrt(Ts)]',...
'Sample time','Ts',...
'position',[140,61,205,99])
add_line([sys,'/',['Plant/Additive',13,'noise']],[210,80;225,80])
add_line([sys,'/',['Plant/Additive',13,'noise']],[80,80;130,80])
set_param([sys,'/',['Plant/Additive',13,'noise']],...
'Mask Display','plot(1:20,rand(1,20))',...
'Mask Type','Input Noise')
set_param([sys,'/',['Plant/Additive',13,'noise']],...
'Mask Dialogue','White noise for continuous (s-domain) systems.\nBand-limited using zero-order-hold.|Noise Variance:|Sample Time:|Seed')
set_param([sys,'/',['Plant/Additive',13,'noise']],...
'Mask Translate','Cov = @1; Ts = @2; seed = @3; r = rand(1,12)-0.5; ')
set_param([sys,'/',['Plant/Additive',13,'noise']],...
'Mask Help','Implemented using white noise into Zero Order Hold block. For faster simulation set sample time to highest value possible but in accordance with the fastest dynamics of system.')
set_param([sys,'/',['Plant/Additive',13,'noise']],...
'Mask Entries','0.001\/0.1\/12345\/')
% Finished composite block ['Plant/Additive',13,'noise'].
set_param([sys,'/',['Plant/Additive',13,'noise']],...
'position',[60,154,105,186])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -