📄 portdemo.m
字号:
function [ret,x0,str]=portdemo(t,x,u,flag);
%PORTDEMO is the M-file description of the SIMULINK system named PORTDEMO.
% The block-diagram can be displayed by typing: PORTDEMO.
%
% SYS=PORTDEMO(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 PORTDEMO 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 PORTDEMO with a FLAG of zero:
% [SIZES]=PORTDEMO([],[],[],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',[18,106,282,357])
open_system(sys)
end;
set_param(sys,'algorithm', 'Euler')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999999')
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/Sine Wave',[sys,'/','Sine Wave'])
set_param([sys,'/','Sine Wave'],...
'position',[60,55,90,85])
% Subsystem 'Composite with Outport'.
new_system([sys,'/','Composite with Outport'])
set_param([sys,'/','Composite with Outport'],'Location',[81,284,311,442])
add_block('built-in/Outport',[sys,'/','Composite with Outport/Outport'])
set_param([sys,'/','Composite with Outport/Outport'],...
'position',[130,25,150,45])
add_block('built-in/White Noise',[sys,'/','Composite with Outport/White Noise'])
set_param([sys,'/','Composite with Outport/White Noise'],...
'position',[40,20,70,50])
add_line([sys,'/','Composite with Outport'],[75,35;120,35])
% Finished composite block 'Composite with Outport'.
set_param([sys,'/','Composite with Outport'],...
'position',[60,150,90,200])
add_block('built-in/Note',[sys,'/','Connections'])
set_param([sys,'/','Connections'],...
'position',[135,10,136,11])
add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'Vgain','2.000000',...
'Hgain','3.000000',...
'Vmax','2.000000',...
'Hmax','6.000000',...
'Window',[322,139,565,284],...
'position',[170,155,200,195])
% Subsystem 'Composite with Inport'.
new_system([sys,'/','Composite with Inport'])
set_param([sys,'/','Composite with Inport'],'Location',[85,170,285,281])
add_block('built-in/Inport',[sys,'/','Composite with Inport/Inport'])
set_param([sys,'/','Composite with Inport/Inport'],...
'position',[25,25,45,45])
add_block('built-in/Scope',[sys,'/','Composite with Inport/Scope'])
set_param([sys,'/','Composite with Inport/Scope'],...
'Vgain','2.000000',...
'Hgain','11.000000',...
'Vmax','2.000000',...
'Hmax','22.000000',...
'Window',[318,414,559,558],...
'position',[115,15,145,55])
add_line([sys,'/','Composite with Inport'],[50,35;105,35])
% Finished composite block 'Composite with Inport'.
set_param([sys,'/','Composite with Inport'],...
'position',[170,45,200,95])
add_line(sys,[95,70;160,70])
add_line(sys,[95,175;160,175])
% 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 + -