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

📄 musyndm1.m

📁 本书是电子通信类的本科、研究生辅助教材
💻 M
字号:
function [ret,x0,str]=musyndm1(t,x,u,flag);
%MUSYNDM1	is the M-file description of the SIMULINK system named MUSYNDM1.
%	The block-diagram can be displayed by typing: MUSYNDM1.
%
%	SYS=MUSYNDM1(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 MUSYNDM1 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 MUSYNDM1 with a FLAG of zero:
%	[SIZES]=MUSYNDM1([],[],[],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',[401,102,1020,400])
     open_system(sys)
end;
set_param(sys,'algorithm',		'Linear')
set_param(sys,'Start time',	'0.0')
set_param(sys,'Stop time',		'9999')
set_param(sys,'Min step size',	'0.002')
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,'/','Sum5'])
set_param([sys,'/','Sum5'],...
		'orientation',1,...
		'position',[395,135,415,155])

add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
		'Peak','2.000000',...
		'Peak Range','10.000000',...
		'Freq','1.000000',...
		'Freq Range','5.000000',...
		'Wave','Sqr',...
		'Units','Rads',...
		'position',[20,18,65,52])

add_block('built-in/Inport',[sys,'/','Inport2'])
set_param([sys,'/','Inport2'],...
		'position',[25,70,45,90])


%     Subsystem  ['Sensor',13,'Noise'].

new_system([sys,'/',['Sensor',13,'Noise']])
set_param([sys,'/',['Sensor',13,'Noise']],'Location',[0,0,262,236])

add_block('built-in/Discrete Transfer Fcn',[sys,'/',['Sensor',13,'Noise/Zero Order Hold']])
set_param([sys,'/',['Sensor',13,'Noise/Zero Order Hold']],...
		'Numerator','[sqrt(Cov)]',...
		'Denominator','[sqrt(Ts)]',...
		'Sample time','Ts',...
		'position',[140,61,205,99])

add_block('built-in/White Noise',[sys,'/',['Sensor',13,'Noise/White Noise']])
set_param([sys,'/',['Sensor',13,'Noise/White Noise']],...
		'Seed','seed',...
		'position',[55,70,75,90])

add_block('built-in/Outport',[sys,'/',['Sensor',13,'Noise/out_1']])
set_param([sys,'/',['Sensor',13,'Noise/out_1']],...
		'position',[235,70,255,90])
add_line([sys,'/',['Sensor',13,'Noise']],[80,80;130,80])
add_line([sys,'/',['Sensor',13,'Noise']],[210,80;225,80])
set_param([sys,'/',['Sensor',13,'Noise']],...
		'Mask Display','plot(1:20,rand(1,20))',...
		'Mask Type','Continuous White Noise.')
set_param([sys,'/',['Sensor',13,'Noise']],...
		'Mask Dialogue','White noise for continuous (s-domain) systems.\nBand-limited using zero-order-hold.|Noise Variance:|Sample Time:|Seed',...
		'Mask Translate','Cov = @1; Ts = @2; seed = @3;')
set_param([sys,'/',['Sensor',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,'/',['Sensor',13,'Noise']],...
		'Mask Entries','0.02\/0.1\/23341\/')


%     Finished composite block ['Sensor',13,'Noise'].

set_param([sys,'/',['Sensor',13,'Noise']],...
		'orientation',2,...
		'position',[460,100,490,130])

add_block('built-in/Outport',[sys,'/','Outport1'])
set_param([sys,'/','Outport1'],...
		'Port','2',...
		'position',[570,181,600,199])

add_block('built-in/Outport',[sys,'/','Outport'])
set_param([sys,'/','Outport'],...
		'position',[540,71,570,89])

add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
		'inputs','-++',...
		'position',[125,62,145,98])

add_block('built-in/State-space',[sys,'/','plant'])
set_param([sys,'/','plant'],...
		'A','a',...
		'B','b',...
		'C','c',...
		'D','d',...
		'Mask Display','',...
		'position',[300,61,375,99])

add_block('built-in/State-space',[sys,'/','controller'])
set_param([sys,'/','controller'],...
		'A','ak',...
		'B','bk',...
		'C','ck',...
		'D','dk',...
		'position',[190,61,265,99])

add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
		'Vgain','5.000000',...
		'Hgain','20.000000',...
		'Vmax','41.666667',...
		'Hmax','40.000000',...
		'Window',[586,141,1013,274],...
		'position',[545,17,565,43])


%     Subsystem  ['Double click here',13,'to show bode plot',13,'of closed-loop3'].

new_system([sys,'/',['Double click here',13,'to show bode plot',13,'of closed-loop3']])
set_param([sys,'/',['Double click here',13,'to show bode plot',13,'of closed-loop3']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to show bode plot',13,'of closed-loop3']],...
		'Mask Display','Closed-Loop\nBode Plot',...
		'Mask Type','')
set_param([sys,'/',['Double click here',13,'to show bode plot',13,'of closed-loop3']],...
		'Mask Dialogue','eval(''if ~exist(''''g1''''),fprintf(''''\nMust Load Data & Design First\n''''),else [x,y,z,w]=unpck(g1); [x,y,z]=bode(x,y,z,w); clg; subplot(211); loglog(z,x(:,1)); subplot(212); semilogx(z,y(:,1)); end'')')
set_param([sys,'/',['Double click here',13,'to show bode plot',13,'of closed-loop3']],...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['Double click here',13,'to show bode plot',13,'of closed-loop3'].

set_param([sys,'/',['Double click here',13,'to show bode plot',13,'of closed-loop3']],...
		'hide name',0,...
		'position',[195,230,275,272])


%     Subsystem  ['Double click here',13,'to start loading data',13,'and mu-syn design2'].

new_system([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design2']])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design2']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design2']],...
		'Mask Display','Re-design',...
		'Mask Type','')
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design2']],...
		'Mask Dialogue','eval(''if ~exist(''''mu''''),fprintf(''''\nMust be licensed for RCT Toolbox\n''''), else, fprintf(''''\nCtrl_C to abort MuSyn Calculation\n\n''''); mudes1; end'')')
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design2']],...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['Double click here',13,'to start loading data',13,'and mu-syn design2'].

set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design2']],...
		'hide name',0,...
		'position',[104,229,182,271])


%     Subsystem  ['Double click here',13,'to start loading data',13,'and mu-syn design1'].

new_system([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],...
		'Mask Display','Re-Load\nData',...
		'Mask Type','')
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],...
		'Mask Dialogue','eval(''if ~exist(''''mu''''),fprintf(''''\nMust be licensed for MuSyn Toolbox\n''''), else, fprintf(''''\nLoading Data\nWarning: New data will overlap the original working space data''''); mudata1; end'')')
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['Double click here',13,'to start loading data',13,'and mu-syn design1'].

set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],...
		'hide name',0,...
		'position',[15,229,93,270])


%     Subsystem  ['Double click here',13,'to show zero-pole',13,'plot of controller'].

new_system([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of controller']])
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of controller']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of controller']],...
		'Mask Display','Controller\nNyquist',...
		'Mask Type','')
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of controller']],...
		'Mask Dialogue','eval(''if ~exist(''''k1''''), printf(''''Must Load Data & Desgin First''''), else,clg,plot(1:10), [x,y,z,w]=unpck(k1); clg, nyquist(x,y,z,w), end'')')
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of controller']],...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['Double click here',13,'to show zero-pole',13,'plot of controller'].

set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of controller']],...
		'hide name',0,...
		'position',[465,230,536,269])


%     Subsystem  ['About the musyn',13,'demo1'].

new_system([sys,'/',['About the musyn',13,'demo1']])
set_param([sys,'/',['About the musyn',13,'demo1']],'Location',[2,439,106,512])
set_param([sys,'/',['About the musyn',13,'demo1']],...
		'Mask Display','?',...
		'Mask Type','',...
		'Mask Dialogue','eval(''clc; more(24); help mudata1; more off'')',...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['About the musyn',13,'demo1'].

set_param([sys,'/',['About the musyn',13,'demo1']],...
		'hide name',0,...
		'position',[548,232,603,269])

add_block('built-in/State-space',[sys,'/','perf. weighting'])
set_param([sys,'/','perf. weighting'],...
		'A','ap',...
		'B','bp',...
		'C','cp',...
		'D','dp',...
		'Mask Display','weighting\nfunc.',...
		'Mask Type','Performance weighting function')
set_param([sys,'/','perf. weighting'],...
		'Mask Dialogue','Performance weighting function:|numerator:|denominator:',...
		'Mask Translate','[ap,bp,cp,dp]=tf2ss(@1,@2);',...
		'Mask Help','This is the weighting function of the plant model.')
set_param([sys,'/','perf. weighting'],...
		'Mask Entries','num\/den\/',...
		'position',[450,171,525,209])


%     Subsystem  ['Double click here',13,'to show bode plot ',13,'of controller'].

new_system([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller']])
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller']],...
		'Mask Display','Closed-Loop\nNyquist',...
		'Mask Type','')
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller']],...
		'Mask Dialogue','eval(''if ~exist(''''g1''''), printf(''''Must Load Data First''''), else, clg, [x,y,z,w]=unpck(g1); nyquist(x,y,z,w), grid; end'')')
set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller']],...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['Double click here',13,'to show bode plot ',13,'of controller'].

set_param([sys,'/',['Double click here',13,'to show bode plot ',13,'of controller']],...
		'hide name',0,...
		'position',[372,229,455,272])


%     Subsystem  ['Double click here',13,'to show zero-pole',13,'plot of closed-loop4'].

new_system([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of closed-loop4']])
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of closed-loop4']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of closed-loop4']],...
		'Mask Display','Controller\nBode Plot',...
		'Mask Type','')
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of closed-loop4']],...
		'Mask Dialogue','eval(''if ~exist(''''k1''''),fprintf(''''\nMust Load Data & Design First\n''''),else [x,y,z,w]=unpck(k1); [x,y,z]=bode(x,y,z,w); clg; subplot(211); loglog(z,x(:,1));subplot(212); semilogx(z,y(:,1)); end'')')
set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of closed-loop4']],...
		'Mask Translate','',...
		'Mask Help','')


%     Finished composite block ['Double click here',13,'to show zero-pole',13,'plot of closed-loop4'].

set_param([sys,'/',['Double click here',13,'to show zero-pole',13,'plot of closed-loop4']],...
		'hide name',0,...
		'position',[285,229,360,273])
add_line(sys,[270,80;290,80])
add_line(sys,[150,80;180,80])
add_line(sys,[70,35;75,35;75,70;115,70])
add_line(sys,[530,190;560,190])
add_line(sys,[50,80;115,80])
add_line(sys,[380,80;530,80])
add_line(sys,[400,80;400,125])
add_line(sys,[455,115;410,115;410,125])
add_line(sys,[405,160;405,190;100,190;100,90;115,90])
add_line(sys,[405,190;440,190])
add_line(sys,[400,80;400,30;535,30])
% 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]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str] = feval(sys);
	end
end

⌨️ 快捷键说明

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