DSPRelated.com
Forums

IIR filter Implementation

Started by Par May 3, 2005
Andre wrote:
> > Why not use an FFT?
An FFT won't help. The signal is short duration (100 samples), hence the FFT will have very poor frequency resolution, hence filtering out a single frequency or a very narrow band will not be possible. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Moore's Law: hardware speed doubles every 18 months Gates' Law: software speed halves every 18 months
Erik wrote:

>An FFT won't help. The signal is short duration (100 samples), hence >the FFT will have very poor frequency resolution, hence filtering out >a single frequency or a very narrow band will not be possible.
Erik, as FFT filtering is equivalent to FIR convolution , you can have any frequency resolution you like (just as you can use any arbitrarily large FIR to filter the 100 samples). However, the output of the linear convolution will be correspondingly long. Perhaps if Par described why he wants to filter the 100 samples, we could suggest an appropriate approach. Is it enough to determine whether the signal with the known frequency is on / off? Is amplitude important? Phase? SNR? Regards, Andor
Andor wrote:
> > Erik, > > as FFT filtering is equivalent to FIR convolution , you can have any > frequency resolution you like (just as you can use any arbitrarily > large FIR to filter the 100 samples).
The resolution of the FFT is limited by the length of the data. Zero padding the data to extend its length does not provide more resolution. As you pointed out, FFT filtering is equivant to FIR filtering so zero padding won't help there either. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ The idea that Bill Gates has appeared like a knight in shining armour to lead all customers out of a mire of technological chaos neatly ignores the fact that it was he who, by peddling second-rate technology, led them into it in the first place. - Douglas Adams in Guardian, 25-Aug-95
<Off topic>
You seem to have a very nice collection of citations!
Is this public domain?


Erik de Castro Lopo wrote:

The idea that Bill Gates has appeared like a knight in shining armour to
lead all customers out of a mire of technological chaos neatly ignores
the fact that it was he who, by peddling second-rate technology, led 
them into it in the first place. - Douglas Adams in Guardian, 25-Aug-95

-- 

Please change no_spam to a.lodwig when replying via email!

>Andor wrote: >> Erik, >> as FFT filtering is equivalent to FIR convolution , you can have any
>> frequency resolution you like (just as you can use any arbitrarily >> large FIR to filter the 100 samples). > >The resolution of the FFT is limited by the length of the data. Zero >padding the data to extend its length does not provide more
resolution. You don't zero pad the data to get more resolution on the data, but to get more resolution on the filter (FIR coefficients). As such, an FFT filter can have any resolution required.
>As you pointed out, FFT filtering is equivant to FIR filtering so zero
>padding won't help there either.
Not quite sure what you mean. There are 100 samples. We want to apply an FIR filter. Depending on the requirements of the FIR filter, there may well be many taps to it (of course, no zero padding but real coefficients) - this can equivalently be coded using FFT filtering. The resolution of the FFT filter (not the data) is not bounded by the amount of data available. Regards, Andor
Andor wrote:
> >Andor wrote: > >> Erik, > >> as FFT filtering is equivalent to FIR convolution , you can > >> have any > > >> frequency resolution you like (just as you can use any > >> arbitrarily large FIR to filter the 100 samples). > > > >The resolution of the FFT is limited by the length of the data. > >Zero padding the data to extend its length does not provide more > resolution. > > You don't zero pad the data to get more resolution on the data, > but to get more resolution on the filter (FIR coefficients). As > such, an FFT filter can have any resolution required.
So you're saying that if I filter 100 data points with a 1,000,000-tap FIR filter, then I get better frequency domain resolution? Poppycock! :-) By taking a 1000-point FFT of 100-point data, you are effectively zero-padding the data. You are not increasing the resolution, because you are limited by your datalength.
> >As you pointed out, FFT filtering is equivant to FIR filtering > > so zero padding won't help there either. > > Not quite sure what you mean. There are 100 samples. We want to > apply an FIR filter. Depending on the requirements of the FIR filter, > there may well be many taps to it (of course, no zero padding but > real coefficients) - this can equivalently be coded using FFT > filtering. The resolution of the FFT filter (not the data) is not > bounded by the amount of data available.
OK, but as soom as you try to apply your high-resolution FFT filter to data, your resolution of the data will be limited by the data length (if it's less than the FFT filter length).... you'll have to zero pad the data. Even if your long FFT filter is an "on-line" type (rather than a block-filter like I've been assuming), you won't get any better resolution on data than that determined by the length of the data. Either you stop the on-line FFT filter after all the data has been input... or you continue the on-line FFT filter and just keep feeding the input with zeros after all the data has been input. In both cases your resolution is constrained by the data length (if it's shorter than the FFT filter length). Ciao, Peter K.
Andor wrote:
> >>Andor wrote: >> >>>Erik, >>>as FFT filtering is equivalent to FIR convolution , you can have any > > >>>frequency resolution you like (just as you can use any arbitrarily >>>large FIR to filter the 100 samples). >> >>The resolution of the FFT is limited by the length of the data. Zero >>padding the data to extend its length does not provide more > > resolution. > > You don't zero pad the data to get more resolution on the data, but to > get more resolution on the filter (FIR coefficients). As such, an FFT > filter can have any resolution required. > > >>As you pointed out, FFT filtering is equivant to FIR filtering so zero > > >>padding won't help there either. > > > Not quite sure what you mean. There are 100 samples. We want to apply > an FIR filter. Depending on the requirements of the FIR filter, there > may well be many taps to it (of course, no zero padding but real > coefficients) - this can equivalently be coded using FFT filtering. The > resolution of the FFT filter (not the data) is not bounded by the > amount of data available.
I can't figure out what you have in mind. There's no use building a 200-tap FIR to filter 100 samples. That will be worse than a 50-tap approximation. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message 
news:3Padncy9g5o-d-XfRVn-pQ@rcn.net...
> Andor wrote: >> >>>Andor wrote: >>> >>>>Erik, >>>>as FFT filtering is equivalent to FIR convolution , you can have any >> >> >>>>frequency resolution you like (just as you can use any arbitrarily >>>>large FIR to filter the 100 samples). >>> >>>The resolution of the FFT is limited by the length of the data. Zero >>>padding the data to extend its length does not provide more >> >> resolution. >> >> You don't zero pad the data to get more resolution on the data, but to >> get more resolution on the filter (FIR coefficients). As such, an FFT >> filter can have any resolution required. >> >> >>>As you pointed out, FFT filtering is equivant to FIR filtering so zero >> >> >>>padding won't help there either. >> >> >> Not quite sure what you mean. There are 100 samples. We want to apply >> an FIR filter. Depending on the requirements of the FIR filter, there >> may well be many taps to it (of course, no zero padding but real >> coefficients) - this can equivalently be coded using FFT filtering. The >> resolution of the FFT filter (not the data) is not bounded by the >> amount of data available. > > I can't figure out what you have in mind. There's no use building a > 200-tap FIR to filter 100 samples. That will be worse than a 50-tap > approximation. > > Jerry
Here's a little exercise in thinking about filters and impulse responses. Here is a notch filter that zeros out signals at f0: +---------+ | | | | x --+------------->| F1 +--->----+ | | | | | | | +----+----+ | +---------+ | + | | | | | | SUM |----------> y | | | | +---------+ +---------+ | + | | | | | | +----+----+ | | | | | | +->| DELAY +-| F1' +--->----+ | >1/B | | | | | | | +---------+ +---------+ F1 is a bandpass filter at f0 with bandwidth B and *high* gain (just to make the point). DELAY is > the length of the impulse response of F1 and such that the output of F1' is out of phase with the output of F1 in steady state. Q: What does the output of the system look like in response to a step tone at f0? A: A large tone burst output that settles to a high level according to the impulse response of F1. It remains until the end of the delay and decays to zero according to the impulse response of F1'. Q: What is the length of the impulse response of the system? A: The delay plus the length of 1x the impulse response of F1 (as in F1'). The point here is that the transient response is *very* different from the steady state response. So the problem of using long filters for short pulses should be apparent. If the input is a burst (not a step) that is limited to a length *that is equal to the delay* then the output will be a burst at f0 for the length of the delay followed by another burst at f0 that is out of phase from the first part of the output. It seems that this type of response is counterintuitive to some who would hope that a filter would do "some good" even for short-duration inputs. Well, some filters like minimum phase filters, might. But not all filters and surely not the one above! Fred
Fred Marshall wrote:

> It seems that this type of response is counterintuitive to some who > would hope that a filter would do "some good" even for short- > duration inputs. Well, some filters like minimum phase filters, > might. But not all filters and surely not the one above!
Nice gedankenproblem (thought problem), Fred! Ciao, Peter K.
Wow! Thanks for the quick and great responses guys.

I do agree that the frequency resolution is limited by the number of
samples.

For my problem, the best solution I could find so far is to use the MATLAB
command filtfilt. It does the zero-phase filtering, and also claims to do
some serious attempts to reduce the transients. I got better results after
using that command. MATLAB refers to an IEEE Transactions paper in the help
documentation for the command filtfilt. This paper details a strategy to
reduce transients which I am trying to understand right now.

Rick Lyons has also mentioned about using the filtfilt command for this
purpose in one of his replies to the newsgroup sometime in 2003. (Rick, I
love your book, by the way!)

Thanks.

--- Par.
		
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com