Message Boards Message Boards

What are the valid specs for a FIR implementation of a bandstop filter?

GROUPS:

Hi all, I am trying to compute the coefficients of a FIR in order to implement a digital bandstop filter. I would like to issue the command

a = LeastSquaresFilterKernel[ {"Bandstop", {{3.70, 11.8}}}, 10^5] 

which would be "find 10^5 coefficients for a bandstop filter with resonance frequency 3.7 Hz and quality factor Q = 11.8" To me this request seems reasonable, at least as reasonable as

a = LeastSquaresFilterKernel[ {"Bandstop", {{1., 10}}}, 10^5 ]; (* works *)

but still, when I issue that in Mathematica I get

LeastSquaresFilterKernel::spec: {Bandstop,{{3.7,11.8}}} is not a valid filter specification.

Anyone knows what's wrong with that? Thank you very much for your suggestions.

Guido

POSTED BY: Guido Fantini
Answer
26 days ago

Guido,

The wc term is not in Hz -- it is a number between 0 and Pi, where Pi is Nyquist frequency. You need to decide on the time spacing of your FIR points (your sample rate) and scale wc accordingly. Also, I am surprised that any real application would require an FIR filter of length 10^5 points -- are you certain you need that many points? Typically the filter is a much shorter "Kernel" that gets convolved with a longer time sequence (maybe 10 up to a few hundred points). If you make the FIR very long, while it may be sharper, you suffer a huge time delay. Also, sharp cutoff filters often suffer from ringing in the time domain.

I hope this helps.

Regards

Neil

POSTED BY: Neil Singer
Answer
19 days ago

Thanks for the reply, in the meantime I tried to do the same with Matlab and realized exactly what you said, that indeed to design a notch filter 3 coefficients could be enough. And also that the wc term is

wc = PI * f_cut / f_nyquist = 2*PI * f_cut / f_s

As soon as I get back to mathematica I will try that and eventually post again. Thanks a lot for the reply, that pointed me to the right direction!

Best, Guido

POSTED BY: Guido Fantini
Answer
11 days ago

Group Abstract Group Abstract