www.gusucode.com > signal 案例源码程序 matlab代码 > signal/BandpassButterDesignfiltExample.m

    %% Bandpass Butterworth Filter
% Design a 20th-order Butterworth bandpass filter with a lower cutoff
% frequency of 500 Hz and a higher cutoff frequency of 560 Hz. Specify a
% sample rate of 1500 Hz. Use the state-space representation. Design an
% identical filter using |designfilt|.

% Copyright 2015 The MathWorks, Inc.


%%

[A,B,C,D] = butter(10,[500 560]/750);
d = designfilt('bandpassiir','FilterOrder',20, ...
    'HalfPowerFrequency1',500,'HalfPowerFrequency2',560, ...
    'SampleRate',1500);

%% 
% Convert the state-space representation to second-order sections.
% Visualize the frequency responses using |fvtool|.

sos = ss2sos(A,B,C,D);
fvt = fvtool(sos,d,'Fs',1500);
legend(fvt,'butter','designfilt')