MATLAB: Design Notching Filter for different frequencies

notching filter

Hi,
I want to design a filter with Notches in different frequencies. The MATLAB give the option for one Notch only:
F0 = 60; % interference is at 60 Hz
Fs = 3000; % sampling frequency is 3000 Hz
BW=1;
f = fdesign.notch('N,F0,BW',2,F0,10,Fs);
h = design(f,'SystemObject',true);
hfvt= fvtool(h,'Color','white');
Any idea how to filter the other frequencies?

Best Answer

You can use dfilt.cascade to combine filters in series.
In the following code, I create two notch filters, and cascade them together.
F0 = 60; % interference is at 60 Hz
Fs = 3000; % sampling frequency is 3000 Hz
BW=1;
f = fdesign.notch('N,F0,BW',2,F0,10,Fs);
h = design(F);
hfvt= fvtool(h,'Color','white');
f2 = fdesign.notch('N,F0,BW',2,F0+300,10,Fs);
h2 = design(f2);
hfvt= fvtool(h2,'Color','white');
hd = dfilt.cascade(h, h2);
hfvt= fvtool(hd,'Color','white');
Related Question