📄 extrfilt.m
字号:
function [ret,x0,str,ts,xts]=extrfilt(t,x,u,flag);
%EXTRFILT is the M-file description of the SIMULINK system named EXTRFILT.
% The block-diagram can be displayed by typing: EXTRFILT.
%
% SYS=EXTRFILT(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 EXTRFILT 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 EXTRFILT with a FLAG of zero:
% [SIZES]=EXTRFILT([],[],[],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',[106,122,499,538])
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', '')
% Subsystem ['Discrete',13,'Highpass'].
new_system([sys,'/',['Discrete',13,'Highpass']])
set_param([sys,'/',['Discrete',13,'Highpass']],'Location',[8,75,168,638])
add_block('built-in/Filter',[sys,'/',['Discrete',13,'Highpass/Classical FIR ',13,'HP Filter']])
set_param([sys,'/',['Discrete',13,'Highpass/Classical FIR ',13,'HP Filter']],...
'Numerator','b',...
'Denominator','1',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','fir1(HP)')
set_param([sys,'/',['Discrete',13,'Highpass/Classical FIR ',13,'HP Filter']],...
'Mask Dialogue','Classical FIR high pass filter.\n\n(Requires Signal Processing Toolbox)|Cutoff frequency (0 to 1):|Order:|Sample time:')
set_param([sys,'/',['Discrete',13,'Highpass/Classical FIR ',13,'HP Filter']],...
'Mask Translate','[b]=fir1(@2,@1,''high''); ts=@3; h=freqz(b,1,64); ',...
'Mask Help','FIR high pass filter using MATLAB''s fir1 command.')
set_param([sys,'/',['Discrete',13,'Highpass/Classical FIR ',13,'HP Filter']],...
'Mask Entries','0.5\/8\/0.1\/',...
'position',[50,73,125,117])
add_block('built-in/Note',[sys,'/',['Discrete',13,'Highpass/Discrete-Time',13,'Highpass Filters']])
set_param([sys,'/',['Discrete',13,'Highpass/Discrete-Time',13,'Highpass Filters']],...
'position',[80,20,85,25])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Highpass/Butterworth',13,'IIR HP Filter']])
set_param([sys,'/',['Discrete',13,'Highpass/Butterworth',13,'IIR HP Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','butter(HP)')
set_param([sys,'/',['Discrete',13,'Highpass/Butterworth',13,'IIR HP Filter']],...
'Mask Dialogue','Butterworth high pass filter.\n(Requires Signal Processing Toolbox)|Cutoff frequency (0 to 1):|Order:|Sample time:')
set_param([sys,'/',['Discrete',13,'Highpass/Butterworth',13,'IIR HP Filter']],...
'Mask Translate','[a,b,c,d]=butter(@2,@1,''high''); ts=@3; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Highpass/Butterworth',13,'IIR HP Filter']],...
'Mask Help','IIR Butterworth high pass filter using MATLAB''s butter command.',...
'Mask Entries','0.5\/4\/0.1\/',...
'position',[50,167,125,213])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Highpass/Chebychev Type I',13,'IIR HP Filter']])
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type I',13,'IIR HP Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','cheby1(HP)')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type I',13,'IIR HP Filter']],...
'Mask Dialogue','IIR Chebychev type I high pass filter.\n\n(Requires Signal Processing Toolbox)|Cutoff frequency (0 to 1):|Order:|Db ripple in passband:|Sample time:')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type I',13,'IIR HP Filter']],...
'Mask Translate','[a,b,c,d]=cheby1(@2,@3,@1,''high''); ts=@4; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type I',13,'IIR HP Filter']],...
'Mask Help','IIR Chebychev type I high pass filter using MATLAB''s cheby1 command.',...
'Mask Entries','0.5\/4\/3\/0.1\/',...
'position',[55,266,115,314])
% Subsystem ['Discrete',13,'Highpass/Elliptic'].
new_system([sys,'/',['Discrete',13,'Highpass/Elliptic']])
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic']],'Location',[8,51,240,278])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Highpass/Elliptic/Elliptic',13,'IIR LP Filter']])
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic/Elliptic',13,'IIR LP Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','ellip(HP)')
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic/Elliptic',13,'IIR LP Filter']],...
'Mask Dialogue','Elliptic high pass filter.\n\n(Requires Signal Processing Toolbox)|Cutoff frequency (0 to 1):|Order:|Db ripple in passband:|Db ripple in stopband:|Sample time:')
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic/Elliptic',13,'IIR LP Filter']],...
'Mask Translate','[a,b,c,d]=ellip(@2,@3,@4,@1,''high''); ts=@5; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic/Elliptic',13,'IIR LP Filter']],...
'Mask Help','IIR elliptic high pass filter using MATLAB''s ellip command.',...
'Mask Entries','0.5\/2\/3\/20\/1\/',...
'position',[85,66,145,114])
add_block('built-in/Note',[sys,'/',['Discrete',13,'Highpass/Elliptic/(May take some time to draw icon)']])
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic/(May take some time to draw icon)']],...
'position',[120,20,125,25])
% Finished composite block ['Discrete',13,'Highpass/Elliptic'].
set_param([sys,'/',['Discrete',13,'Highpass/Elliptic']],...
'position',[70,464,100,510])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Highpass/Chebychev Type II',13,'IIR HP Filter']])
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type II',13,'IIR HP Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','cheby2(HP)')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type II',13,'IIR HP Filter']],...
'Mask Dialogue','Chebychev type II low pass filter.\n(Requires Signal Processing Toolbox)|Cutoff frequency (0 to 1):|Order:|Db ripple in stopband:|Sample time:')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type II',13,'IIR HP Filter']],...
'Mask Translate','[a,b,c,d]=cheby2(@2,@3,@1,''high''); ts=@4; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type II',13,'IIR HP Filter']],...
'Mask Help','IIR Chebychev type II high pass filter using MATLAB''s cheby2 command.',...
'Mask Entries','0.5\/4\/20\/0.1\/')
set_param([sys,'/',['Discrete',13,'Highpass/Chebychev Type II',13,'IIR HP Filter']],...
'position',[55,361,115,409])
% Finished composite block ['Discrete',13,'Highpass'].
set_param([sys,'/',['Discrete',13,'Highpass']],...
'position',[320,178,350,232])
% Subsystem ['Discrete',13,'Bandstop'].
new_system([sys,'/',['Discrete',13,'Bandstop']])
set_param([sys,'/',['Discrete',13,'Bandstop']],'Location',[8,75,168,638])
% Subsystem ['Discrete',13,'Bandstop/Elliptic'].
new_system([sys,'/',['Discrete',13,'Bandstop/Elliptic']])
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic']],'Location',[8,51,240,278])
add_block('built-in/Note',[sys,'/',['Discrete',13,'Bandstop/Elliptic/(May take some time to draw icon)']])
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic/(May take some time to draw icon)']],...
'position',[120,20,125,25])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Bandstop/Elliptic/Elliptic',13,'IIR BS Filter']])
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic/Elliptic',13,'IIR BS Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','ellip(BS)')
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic/Elliptic',13,'IIR BS Filter']],...
'Mask Dialogue','Elliptic band stop filter.\n\n(Requires Signal Processing Toolbox)|Center frequency (0 to 1):|Bandwidth (0 to 1):|Order:|Db ripple in passband:|Db ripple in stopband:|Sample time:')
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic/Elliptic',13,'IIR BS Filter']],...
'Mask Translate','bw = @2/2; [a,b,c,d]=ellip(@3,@4,@5,[@1-bw,@1+bw],''stop''); ts=@6; [num,den]=ss2tf(a,b,c,d,1); if (@3 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic/Elliptic',13,'IIR BS Filter']],...
'Mask Help','IIR elliptic band stop filter using MATLAB''s ellip command.',...
'Mask Entries','0.5\/0.5\/3\/1\/20\/0.05\/')
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic/Elliptic',13,'IIR BS Filter']],...
'position',[85,66,145,114])
% Finished composite block ['Discrete',13,'Bandstop/Elliptic'].
set_param([sys,'/',['Discrete',13,'Bandstop/Elliptic']],...
'position',[70,464,100,510])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Bandstop/Chebychev Type II',13,'IIR BS Filter']])
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type II',13,'IIR BS Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','cheby2(BS)')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type II',13,'IIR BS Filter']],...
'Mask Dialogue','Chebychev type II band pass filter.\n(Requires Signal Processing Toolbox)|Center frequency (0 to 1):|Bandwidth (0 to 1):|Order:|Db ripple in stopband:|Sample time:')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type II',13,'IIR BS Filter']],...
'Mask Translate','bw = @2/2; [a,b,c,d]=cheby2(@3,@4,[@1-bw,@1+bw],''stop''); ts=@5; [num,den]=ss2tf(a,b,c,d,1); if (@3 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type II',13,'IIR BS Filter']],...
'Mask Help','IIR Chebychev type II band stop filter using MATLAB''s cheby2 command.',...
'Mask Entries','0.5\/0.5\/5\/20\/0.1\/')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type II',13,'IIR BS Filter']],...
'position',[55,356,115,404])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Bandstop/Chebychev Type I',13,'IIR BS Filter']])
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type I',13,'IIR BS Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','cheby1(BS)')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type I',13,'IIR BS Filter']],...
'Mask Dialogue','IIR Chebychev type I band stop filter.\n\n(Requires Signal Processing Toolbox)|Center frequency (0 to 1):|Bandwidth (0 to 1):|Order:|Db ripple in passband:|Sample time:')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type I',13,'IIR BS Filter']],...
'Mask Translate','bw = @2/2; [a,b,c,d]=cheby1(@3,@4,[@1-bw,@1+bw],''stop''); ts=@5; [num,den]=ss2tf(a,b,c,d,1); if (@3 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type I',13,'IIR BS Filter']],...
'Mask Help','IIR Chebychev type I band stop filter using MATLAB''s cheby1 command.',...
'Mask Entries','0.5\/0.5\/3\/1\/0.1\/')
set_param([sys,'/',['Discrete',13,'Bandstop/Chebychev Type I',13,'IIR BS Filter']],...
'position',[55,266,115,314])
add_block('built-in/Discrete State-Space',[sys,'/',['Discrete',13,'Bandstop/Butterworth',13,'IIR BS Filter']])
set_param([sys,'/',['Discrete',13,'Bandstop/Butterworth',13,'IIR BS Filter']],...
'A','a',...
'B','b',...
'C','c',...
'D','d',...
'Sample time','ts',...
'Mask Display','plot(1:64,abs(h))',...
'Mask Type','butter(BS)')
set_param([sys,'/',['Discrete',13,'Bandstop/Butterworth',13,'IIR BS Filter']],...
'Mask Dialogue','Butterworth band pass filter.\n(Requires Signal Processing Toolbox)|Center frequency (0 to 1):|Bandwidth (0 to 1):|Order:|Sample time:')
set_param([sys,'/',['Discrete',13,'Bandstop/Butterworth',13,'IIR BS Filter']],...
'Mask Translate','bw = @2/2; [a,b,c,d]=butter(@3,[@1-bw,@1+bw],''stop''); ts=@4; [num,den]=ss2tf(a,b,c,d,1); if (@3 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Discrete',13,'Bandstop/Butterworth',13,'IIR BS Filter']],...
'Mask Help','IIR Butterworth band stop filter using MATLAB''s butter command.',...
'Mask Entries','0.5\/0.5\/5\/0.1\/',...
'position',[50,167,125,213])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -