DSPRelated.com
Forums

IIR filter Implementation

Started by Par May 3, 2005
Andre wrote:
> > <Off topic> > You seem to have a very nice collection of citations!
Thanks.
> Is this public domain?
I'm pretty sure that The Guardian newsgapaper holds copyright on that quotation, but my usage of it would be well within the realms of fair use. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "No Silicon Heaven? Preposterous! Where would all the calculators go?" -- Kryten, Red Dwarf
"Par" <rpara26@yahoo.com> wrote in message 
news:m8edneNpZsC_lOXfRVn-oA@giganews.com...
> Hello Guys! > > I have a brief signal, about 100 values, having unknown frequency > components including a single frequency of interest to me. I have designed > an IIR filter using MATLAB that will filter out the single frequency.
It sounds like filtering is just not what you want to do. If you could you describe the application, i.e., how you get those 100 values and what kind of meaning you want to extract from them, I'm sure we could help. -- Matt
> >It sounds like filtering is just not what you want to do. > >If you could you describe the application, i.e., how you get those 100 >values and what kind of meaning you want to extract from them, I'm sure
we
>could help. > >-- >Matt >
The 100 values are not obtained by sampling any continuous signal. They are just available as a sequence of numbers. If I assume a normalized sampling rate and take its DFT, I get a spectrum having numerous frequencies. I am interested in only one of them and I know which one. I want to see where in the time-domain signal, that particular freq. is dominant. So, if I filter out that frequency, and then may be see the energy/power of the output signal, I think I will get an idea of the dominance of the freq. What do you think? --- Par. This message was sent using the Comp.DSP web interface on www.DSPRelated.com
Par wrote:
>>It sounds like filtering is just not what you want to do. >> >>If you could you describe the application, i.e., how you get those 100 >>values and what kind of meaning you want to extract from them, I'm sure > > we > >>could help. >> >>-- >>Matt >> > > > The 100 values are not obtained by sampling any continuous signal. They > are just available as a sequence of numbers. If I assume a normalized > sampling rate and take its DFT, I get a spectrum having numerous > frequencies. I am interested in only one of them and I know which one. > > I want to see where in the time-domain signal, that particular freq. is > dominant. So, if I filter out that frequency, and then may be see the > energy/power of the output signal, I think I will get an idea of the > dominance of the freq. What do you think?
You may learn whether that frequency was strong in the interval that the samples represent. You won't learn where within the interval, and you wont know about dominance unless you know the strengths of the other frequencies and can compare. 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;
>You may learn whether that frequency was strong in the interval that the
>samples represent. You won't learn where within the interval, and you >wont know about dominance unless you know the strengths of the other >frequencies and can compare. > >Jerry >--
I don't want to compare the strength of that freq. with the other freqs. I am not concerned about the other freqs. at all. I just want to see if there are any particular portions within the interval of the samples where the freq. is stronger than at other portions within that interval. As I do not have any information about the signal outside that interval, I understand I am very restricted as far as the freqs. I can identify, particularly the low freqs. that spread out far beyond the range of the samples to complete a full cycle. However, this is the problem with any already-digitized sequence. If we do not know at exactly what freq. the original signal was sampled, then the best we can do is to assume a normalized sampling freq. to take a DFT, I think. --- Par. This message was sent using the Comp.DSP web interface on www.DSPRelated.com
"Par" <rpara26@yahoo.com> wrote in message 
news:-4ydnYsZu5nCeuffRVn-gA@giganews.com...
> The 100 values are not obtained by sampling any continuous signal. They > are just available as a sequence of numbers. If I assume a normalized > sampling rate and take its DFT, I get a spectrum having numerous > frequencies. I am interested in only one of them and I know which one.
They have to come from somewhere.
> I want to see where in the time-domain signal, that particular freq. is > dominant. So, if I filter out that frequency, and then may be see the > energy/power of the output signal, I think I will get an idea of the > dominance of the freq. What do you think?
I think you think that you are looking for a frequency, but you are actually looking for something else, and that you wont say what that something else is because you think you're looking for a frequency. If, for example, you are looking for a burst inside the 100 samples with a known waveform in a noisy background, then you can use a matched filter to find it. If you are looking for a tone burst with a known envelope, but arbitrary phase, then you can use a matched pair. If you are expecting the tone to be present across all 100 samples, then you can do a 1-bin DFT, etc. Everything you know about the signal you're looking for and the background noise can be used to help you. -- Matt
Interesting thought experiment.  What happens when you run the below
filter backwards in "time"?  Backwards and forwards (bidirectionally)?

In article <VpidncHKpuOWlOTfRVn-1Q@centurytel.net>,
Fred Marshall <fmarshallx@remove_the_x.acm.org> wrote:
> >"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 > > > > >
IMHO. YMMV. -- Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/ #include <canonical.disclaimer> // only my own opinions, etc.
In article <4278BE7F.E498F49B@mega-nerd.com>,
Erik de Castro Lopo  <nospam@mega-nerd.com> wrote:
>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.
Not true. If the noise level is low enough then the new bins provided by zero padding the input to a larger FFT will increase the measurement accuracy of single frequencies, and perhaps even pairwise resolution of multiple frequencies. I, and at least on other poster in comp.dsp, have tested this on simulated data in a noiseless background; and it works. Realistically, the limit to resolution is eventually bounded by the quantization noise of your data representation or acquisition. The reason this works is that zero padding is a computationally efficient way of Sync interpolation of the frequency data; and Sync interpolation (with a wide enough window) is more correct than linear or quadratic interpolation. The Sync function is "wrinkled" enough so that after interpolation using a wide enough window, you might find more local maxima/minima than in just the FFT result bins alone. But the new "wrinkles" are small enough that they are easily overwhelmed by any noise. IMHO. YMMV. -- Ron Nicholson rhn AT nicholson DOT com http://www.nicholson.com/rhn/ #include <canonical.disclaimer> // only my own opinions, etc.
"Ronald H. Nicholson Jr." wrote:
> > In article <4278BE7F.E498F49B@mega-nerd.com>, > Erik de Castro Lopo <nospam@mega-nerd.com> wrote: > >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. > > Not true. If the noise level is low enough then the new bins provided > by zero padding the input to a larger FFT will increase the measurement > accuracy of single frequencies,
Yes, for single frequencies you will get better resolution of the peak frequency.
> and perhaps even pairwise resolution of multiple frequencies.
This part I don't agree with and this is the case the original poster was interested in (ie retrieving a single frequency from a signal containing many unknown components). To prove that you are right and I am wrong you need to show me a signal N samples long with two sinusiodal frequency components. You also need to show that for an N point FFT you only get one peak and for the zero padded version of the signal (padded with 1 or more zeroes) you get both peaks. Feel free to use any window type you please, including rectangular. Alternatively, you can prove your assertion mathematically or provide a reference to such a proof. Good luck, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Failure is not an option. It comes bundled with your Microsoft product.
Fred Marshall wrote:

   ...

> 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.
It is apparent to me for another reason. Numerical filters work by combining scaled samples from various times to form their outputs. (Analog filters work the same way, but the mechanism is less obvious) For the filter to work, all the samples must be available. A long filter -- any filter with a long impulse response -- needs more samples than are available, the number assumed in its design. ...
> Well, some filters like minimum phase filters, might....
I doubt that, for the reason I gave above. 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;