1
$\begingroup$

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 enter image description here

Here is the result after applying the filter cited above: enter image description here I don't get the awaited result. Is there a way to accomplish this in Matlab?

$\endgroup$
4
  • $\begingroup$ Can you share the signal file with us? $\endgroup$
    – learner
    Commented Aug 20, 2017 at 21:13
  • $\begingroup$ 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... $\endgroup$
    – Fat32
    Commented Aug 20, 2017 at 21:14
  • $\begingroup$ @Fat32 I've shared the spectra $\endgroup$
    – chsafouane
    Commented Aug 20, 2017 at 21:27
  • $\begingroup$ 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. $\endgroup$
    – Fat32
    Commented Aug 20, 2017 at 22:09

1 Answer 1

1
$\begingroup$

You have a problem with the comb filter design. According to Matlab documentation the following line creates the filter you want:

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

Looking at the frequency response of the designed filter: enter image description here

Seems to be able to solve your problem...

$\endgroup$
1
  • $\begingroup$ @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. $\endgroup$
    – Fat32
    Commented Aug 21, 2017 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.