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

    %% Bandpass Butterworth Filter
% Design a bandpass filter with a passband from 60 to 200 Hz with at most 3
% dB of passband ripple and at least 40 dB attenuation in the stopbands.
% Specify a sampling rate of 1 kHz. Have the stopbands be 50 Hz wide on
% both sides of the passband. Find the filter order and cutoff frequencies.

% Copyright 2015 The MathWorks, Inc.


%%
Wp = [60 200]/500;
Ws = [50 250]/500;
Rp = 3;
Rs = 40;
[n,Wn] = buttord(Wp,Ws,Rp,Rs)

%%
% Specify the filter in terms of second-order sections and plot the
% frequency response.

[z,p,k] = butter(n,Wn);
sos = zp2sos(z,p,k);

freqz(sos,128,1000)
title(sprintf('n = %d Butterworth Bandpass Filter',n))