📄 tcmplxfl.m
字号:
function [ret,x0,str,ts,xts]=tcmplxfl(t,x,u,flag);
%TCMPLXFL is the M-file description of the SIMULINK system named TCMPLXFL.
% TCMPLXFL has a the following characteristics:
% 0 continuous states
% 38 discrete states
% 0 outputs
% 0 inputs
% does not have direct feedthrough
% 1 sample times
%
% The block-diagram can be displayed by typing: TCMPLXFL.
%
% SYS=TCMPLXFL(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 TCMPLXFL 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 TCMPLXFL with a FLAG of zero:
% [SIZES]=TCMPLXFL([],[],[],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',[161,475,712,675])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999999')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
set_param(sys,'Load callback','M=16;td=.1;ts=.01;Fc=100/pi/2;[num,den]=butter(5,Fc*2*ts);');
add_block('built-in/Signal Generator',[sys,'/',['Signal',13,'generator']])
set_param([sys,'/',['Signal',13,'generator']],...
'hide name',0,...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','1.000000',...
'Freq Range','5.000000',...
'Wave','Sin',...
'Units','Rads',...
'position',[30,73,75,107])
add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
'hide name',0,...
'inputs','2',...
'position',[135,111,170,144])
add_block('built-in/Filter',[sys,'/','Real filter'])
set_param([sys,'/','Real filter'],...
'Numerator','[1 2 3 4 5 6 7 8]',...
'Denominator','[5 4 3 2 1]',...
'Sample time','.1',...
'position',[110,45,360,85])
add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
'hide name',0,...
'inputs','2',...
'position',[395,106,430,139])
% Subsystem ['Auto-Scale',13,'Graph'].
new_system([sys,'/',['Auto-Scale',13,'Graph']])
set_param([sys,'/',['Auto-Scale',13,'Graph']],'Location',[0,59,274,252])
add_block('built-in/Inport',[sys,'/',['Auto-Scale',13,'Graph/x']])
set_param([sys,'/',['Auto-Scale',13,'Graph/x']],...
'position',[65,55,85,75])
add_block('built-in/S-Function',[sys,'/',['Auto-Scale',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Auto-Scale',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']],...
'function name','sfunyst',...
'parameters','ax, color, npts, dt',...
'position',[130,55,180,75])
add_line([sys,'/',['Auto-Scale',13,'Graph']],[90,65;125,65])
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
'Mask Type','Storage scope.')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):|Sample time:')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=@6;')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Help','Uses MATLAB''s graph window.\nUse only one block per system.\nLine type must be in quotes.\nSee the M-file sfunyst.m.')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Entries','5\/-3\/3\/200\/''y-/g--/c-./w:/m*/ro/b+''\/.1\/')
% Finished composite block ['Auto-Scale',13,'Graph'].
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'hide name',0,...
'position',[450,105,480,145])
add_block('built-in/S-Function',[sys,'/','Complex filter'])
set_param([sys,'/','Complex filter'],...
'function name','cmplxflt',...
'parameters','num, den, ts',...
'Mask Display','plot(0,0,100,100,x,y,u,v);Filter',...
'Mask Type','Complex filter')
set_param([sys,'/','Complex filter'],...
'Mask Dialogue','Vector expression for numerator and\ndenominator. Complex coefficients are in ascending power of 1/z.|Numerator:|Denominator:|Sample time:')
set_param([sys,'/','Complex filter'],...
'Mask Translate','num=@1;den=@2;ts=@3;num=[real(num(:))'';imag(num(:))''];den=[real(den(:))'';imag(den(:))''];if max(abs(den(2,:))) <=0, den=den(1,:); end;if max(abs(num(2,:))) <=0, num=num(1,:); end;[u,v]=cmplxicn(1,50,get_param(gcb,''orientation''));[x,y]=cmplxicn(0,50,get_param(gcb,''orientation''));')
set_param([sys,'/','Complex filter'],...
'Mask Help','This block takes real or complex signal input and outputs complex signal. The numerator can be a real or a complex vector with the coeficient ordered in ascending power of 1/z. Same for the denominator.')
set_param([sys,'/','Complex filter'],...
'Mask Entries','sqrt(-1)*[1 2 3 4 5 6 7 8]\/[5 4 3 2 1]\/.1\/',...
'position',[225,108,300,152])
add_line(sys,[80,90;90,90;90,120;130,120])
add_line(sys,[90,120;90,135;130,135])
add_line(sys,[90,90;90,65;105,65])
add_line(sys,[435,125;445,125])
add_line(sys,[175,130;220,130])
add_line(sys,[305,130;390,130])
add_line(sys,[365,65;375,65;375,115;390,115])
drawnow
% 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
else
drawnow % Flash up the model and execute load callback
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -