www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/StopbandConstraintsExample.m

    %% Stopband Constraints
% You can specify the shape of the stopband and the rate at which the
% stopband decays.
%
% Create two FIR equiripple filters with different linear stopband slopes.
% Specify the passband frequency to be 0.3π rad/sample and the stopband
% frequency to be 0.35π rad/sample. Specify 1 dB of allowable passband
% ripple and a stopband attenuation of 60 dB. Design one filter with a 20
% dB/(rad/sample) stopband slope and another filter with a slope of 40
% dB/(rad/sample).

D = fdesign.highpass('Fst,Fp,Ast,Ap',0.3,0.35,60,1);
Hd1 = design(D,'equiripple','StopBandShape','linear','StopBandDecay',20);
Hd2 = design(D,'equiripple','StopBandShape','linear','StopBandDecay',40);

%%
% Visualize the magnitude responses of the filters.

hfvt = fvtool([Hd1 Hd2]);
legend(hfvt,'20 dB/rad/sample','40 dB/rad/sample')