📄 ppfx.m
字号:
function [ret,x0,str,ts,xts]=ppfx(t,x,u,flag);
%PPFX is the M-file description of the SIMULINK system named PPFX.
% The block-diagram can be displayed by typing: PPFX.
%
% SYS=PPFX(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 PPFX 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 PPFX with a FLAG of zero:
% [SIZES]=PPFX([],[],[],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',[117,48,530,308])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '40')
set_param(sys,'Min step size', '0.001')
set_param(sys,'Max step size', '0.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Zero-Pole',[sys,'/',[' 巴特沃斯低通',13,' 滤波器']])
set_param([sys,'/',[' 巴特沃斯低通',13,' 滤波器']],...
'Font Name','宋体',...
'Font Size',12,...
'Zeros','z',...
'Poles','p',...
'Gain','k',...
'Mask Display','plot(20*log10(w),20*log10(abs(h)))',...
'Mask Type','buttap')
set_param([sys,'/',[' 巴特沃斯低通',13,' 滤波器']],...
'Mask Dialogue','Analog Butterworth low pass filter.\n\n(Requires Signal Processing Toolbox)|Cutoff frequency (rad/sec)|Order')
set_param([sys,'/',[' 巴特沃斯低通',13,' 滤波器']],...
'Mask Translate','[z,p,k]=buttap(@2); z=@1*z; p=@1*p; k=real(prod(-p)); [num,den]=zp2tf(z,p,k); w=logspace(log10(@1/10),log10(10*@1),20); h=freqs(num,den,w); ')
set_param([sys,'/',[' 巴特沃斯低通',13,' 滤波器']],...
'Mask Help','Butterworth low pass filter using MATLAB''s butter command.',...
'Mask Entries','200\/4\/',...
'position',[145,138,205,182])
add_block('built-in/Signal Generator',[sys,'/','信号发生器'])
set_param([sys,'/','信号发生器'],...
'Font Name','宋体',...
'Font Size',12,...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','5.000000',...
'Freq Range','50.000000',...
'Wave','Sqr',...
'Units','Rads')
set_param([sys,'/','信号发生器'],...
'position',[55,143,100,177])
add_block('built-in/Scope',[sys,'/',['示波器',13,'(输入信号)']])
set_param([sys,'/',['示波器',13,'(输入信号)']],...
'Font Name','宋体',...
'Font Size',12,...
'Vgain','1.500000',...
'Hgain','30.000000',...
'Vmax','3.000000',...
'Hmax','60.000000',...
'Window',[397,405,729,556])
set_param([sys,'/',['示波器',13,'(输入信号)']],...
'position',[290,27,320,63])
% Subsystem ' 频谱分析'.
new_system([sys,'/',' 频谱分析'])
set_param([sys,'/',' 频谱分析'],'Location',[0,0,276,140])
add_block('built-in/S-Function',[sys,'/',[' 频谱分析/S-function block ',13,'which calls M-file']])
set_param([sys,'/',[' 频谱分析/S-function block ',13,'which calls M-file']],...
'function name','sfunpsd',...
'parameters','fftpts,npts,HowOften,offset,ts,0',...
'position',[160,46,210,84])
add_block('built-in/Inport',[sys,'/',' 频谱分析/input signal'])
set_param([sys,'/',' 频谱分析/input signal'],...
'position',[50,55,70,75])
add_line([sys,'/',' 频谱分析'],[75,65;155,65])
set_param([sys,'/',' 频谱分析'],...
'Mask Display','plot(0,0,100,100,[14,91,91,14,14],[86,86,40,40,86],[85,82,80,79,75,67,63,60,57,53,41,36,33,27,24],[49,50,53,50,49,51,54,66,54,50,50,52,81,51,49])',...
'Mask Type','Spectrum analyzer.')
set_param([sys,'/',' 频谱分析'],...
'Mask Dialogue','Spectrum analyser using graph window.|Length of buffer:|Number of points for fft:|Plot after how many points:|Sample time:')
set_param([sys,'/',' 频谱分析'],...
'Mask Translate','npts=@1; fftpts=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',' 频谱分析'],...
'Mask Help','This block when hooked to the output of a system displays the frequency content of the buffer in the graph window. For more see the M-file specanal.',...
'Mask Entries','256\/512\/64\/0.1\/')
% Finished composite block ' 频谱分析'.
set_param([sys,'/',' 频谱分析'],...
'Font Name','宋体',...
'Font Size',12,...
'Drop Shadow',4,...
'position',[295,110,325,150])
add_block('built-in/Scope',[sys,'/',['示波器',13,'(输出信号)']])
set_param([sys,'/',['示波器',13,'(输出信号)']],...
'Font Name','宋体',...
'Font Size',12,...
'Vgain','1.500000',...
'Hgain','30.000000',...
'Vmax','3.000000',...
'Hmax','60.000000',...
'Window',[4,384,336,546])
set_param([sys,'/',['示波器',13,'(输出信号)']],...
'position',[300,177,330,213])
add_line(sys,[105,160;140,160])
add_line(sys,[210,160;240,160;240,130;290,130])
add_line(sys,[240,160;240,195;295,195])
add_line(sys,[115,160;115,45;285,45])
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 + -