%% Design Equiripple FIR Bandstop Filter
% Design a constrained-band FIR equiripple filter of order 60 with a stopband of [12.8 22.4] kHz. Both passband ripple values are constrained to 1 dB. The sample rate is 64 kHz.
% Create a bandstop filter design specification object using the fdesign.bandstop function and specify these design parameters.

bandstopSpecs = fdesign.bandstop('N,Fp1,Fst1,Fst2,Fp2,C',60,9.6e3,12.8e3,22.4e3,25.6e3,64000);

% Constrain the two passbands with a passband ripple of 1 dB.

bandstopSpecs.Passband1Constrained = true;
bandstopSpecs.Apass1 = 1;
bandstopSpecs.Passband2Constrained = true;
bandstopSpecs.Apass2 = 1;

%
% Design the bandstop filter using the design function. The resulting filter is a dsp.Filter System object™. For details on how to apply this filter on streaming data, refer to dsp.FIRFilter.

bandstopFilt = design(bandstopSpecs,'Systemobject',true)

%
% Visualize the frequency response of the designed filter using fvtool.

fvtool(bandstopFilt)

% Measure the frequency response characteristics of the filter using measure.

measure(bandstopFilt)

%
% Copyright 2019 The MathWorks, Inc.