# Bandpass fundamental and harmonics in Matlab

I have a signal in time domain whose sample frequency is Fs=25600. I would like to remove from the fundamental F=285Hz and all its harmonics (2*F,3*F,etc). I tried to use the comb filter in Matlab using this code :

Fs=25600;
N=43;
BW=285;
Apass=200;
[b, a] = iircomb(N, BW/(Fs/2), Apass);
Hd= dfilt.df2(b, a);
x1 = filter(b, a, signal);


Here is the spectrum of the original signal over the frequency interval up to around 400Hz Here is the result after applying the filter cited above: I don't get the awaited result. Is there a way to accomplish this in Matlab?

• Can you share the signal file with us? Aug 20, 2017 at 21:13
• Can you please show your input and output signals, designed filter impulse response and frequency response etc, both as plots and as data files appreciated... Aug 20, 2017 at 21:14
• @Fat32 I've shared the spectra Aug 20, 2017 at 21:27
• Nice. What about the filter? Please also plot its frequency response. It's bettter if you plot the full spectrum of the filter. Not everybody has the access to the function iircomb. It will be better if you could also upload the filter coefficients a and b for similar reasons. Aug 20, 2017 at 22:09

[b,a] = iircomb(round(25600/285), 2*285/25600/35,'peak');

Looking at the frequency response of the designed filter: • @chsafouane Note that since your fundamental frequency $f_o=285$ Hz do not divide the sampling frequency $F_s = 25600$ Hz in an integer number of times, the exact notch/peak frequency you get will not be $285$ Hz by this design method, unless you change your sampling frequency properly. Also note that the Matlab function options notch and peak do not place the central frequencies at the same place. Aug 21, 2017 at 15:33