DSPRelated.com
Forums

Fir design using the windowing method

Started by bob ockel April 26, 2007
hiya,

This question centers around the difference between having an odd or even
number of taps in an FIR filter.

I'm trying to determine the coefficients of and FIR filter in mathematica.
To do this i've used what i think is called the windowing method, where I
take my ideal frequency response and transform it from frequency space into
time space with a DTFT to get an impulse response. As i understand it, the
coefficients should be symmetrical about the middle of the set.

Because the frequency response can be thought of as periodic with even
symmetry, I use this Fourier cosine series to get my tap values.

for each tap (n) I compute:

(1/Pi) NIntegrate[H[f]Cos[m[n]*f],{f,0,Pi}]
Nintegrate is the numerical integration function in mathematica.

my desired frequency response is:
H[f_] = 1/(1+(X/f)^2)
where X is a value that sets my cutoff frequency

also:
m[n_] = n-(Ns-1)/2

where Ns is the total number of taps. this function m(n) makes my
coefficents symmetrical (ie: a[0] = a[Ns])

Evaluating all this works fine with an odd number of taps, but when if i
change the number of taps from 63 to 64, my impulse response looks
completely aliased and the frequency response gets highly unstable towards
Pi radians, and suddenly drops to zero at Pi (this is a high pass filter).
subtracting 1/2 from m(n) with an even number of taps fixes everything
again, but the resulting coefficients have the same symmetry as an odd
number of taps ( instead of ( a b c d d c b a ) i get ( a b c d c b a e ) ).

Really, i know, this doesn't matter. I can have a filter that works just
fine. But I'm curious why i cannot make the filter work the way i think it
should with an even number of taps. The resource i'm using
coincidentally only uses odd numbers of taps in all of its examples.

thanks,
robert