DSPRelated.com
Forums

Filter design with 'freqsamp' method?

Started by Pete Fraser June 30, 2010
On Thu, 1 Jul 2010 18:48:22 -0700, "Pete Fraser" <pfraser@covad.net> wrote:

>I think I must be doing something dumb. >I started off with a really simple half-band FIR, just >as a test.
...
>The center is 0.5, four are close to 0, >but 0.29 is not 0.32, and -0.04 is not -0.08. > >What am I doing wrong?
You are expecting a generic least-squares fit to produce a symmetric filter, without telling the algorithm to expect symmetry. If you know that your filter is symmetric, you should constrain FDLS to guarantee it: Standard FDLS formulation (set up for zero-order denominator): -1 -n b + b z + ... + b z y(z) 0 1 n ---- = ----------------------- u(z) 1 Constrained formulation: -1 -(n-1) -n b + b z + ... + b z + b z y(z) 0 1 1 0 ---- = ----------------------------------- u(z) 1 Greg
In fact, if you know that your filter is halfband (every other coefficient is
zero), you should also constrain for that:

Standard FDLS formulation (set up for zero-order denominator):

                      -1            -n
               b + b z   + ... + b z
        y(z)    0   1             n
        ---- = -----------------------
        u(z)              1

Constrained formulation:

                      -2            -(n-2)      -n
               b + b z   + ... + b z       + b z
        y(z)    0   2             2           0
        ---- = -----------------------------------
        u(z)                  1

Always try to use as much information as as you have.

Greg
"Greg Berchin" <gberchin@comicast.net.invalid> wrote in message 
news:uchr26djlcjnmrmvi4k94ue126i7sf9vov@4ax.com...

> You are expecting a generic least-squares fit to produce a symmetric > filter, > without telling the algorithm to expect symmetry.
I thought I was doing that be specifying a linear phase response but, of course, the FDLS is just using the phase response as a goal. It can do a better match for my requested amplitude response by using an asymmetric kernel, so it does. Is that correct?
> If you know that your filter > is symmetric, you should constrain FDLS to guarantee it:
I'm using version 2.0 (10/21/2006) and I don't see any way of constraining the filter to be symmetrical (or will I need to tweak the code)? Thanks for a nice tool and tutorial. Pete
On Fri, 2 Jul 2010 09:46:15 -0700, "Pete Fraser" <pfraser@covad.net> wrote:

>I thought I was doing that be specifying a linear phase response but, >of course, the FDLS is just using the phase response as a goal. >It can do a better match for my requested amplitude response by >using an asymmetric kernel, so it does. >Is that correct?
It's just a pseudoinverse and it's just data. Truncation and rounding, numerical ill-conditioning, etc., all affect the result. Also, you are trying to identify nine coefficients with only eleven data points. It should be sufficient, but give it some more data to work with anyway.
>I'm using version 2.0 (10/21/2006) and I don't see any way >of constraining the filter to be symmetrical (or will I need to >tweak the code)?
The Matlab code is only intended to be a starting point, an introductory example. The possibilities for variations on FDLS are limitless. So modify the code to fit your specific problem. I won't mind!
>Thanks for a nice tool and tutorial.
You're welcome. Greg
> > >Pete Fraser wrote: > >> "Vladimir Vassilevsky" <nospam@nowhere.com> wrote in message >> news:0Jidnc3knONVbbbRnZ2dnUVZ_oSdnZ2d@giganews.com... >> >> >>>But why would anyone want to emulate Butterworth magnitude response in a
>>>linear phase FIR filter whereas it is very straightforward to do the >>>(**exact) Butterworth as IIR filter? >> >> >> Butterworth will be one of several possible responses >> from the same hardware. >> >> I'd rather not deal with Butterworth's phase issues. >
Maybe this could help: http://www.icsi.berkeley.edu/~storn/fiwiz.html In the 'Z plane design' option, you pretty much can give it your desired magnitude response and press 'search'... At the very least, it's quite interesting to look at the genetic algorithm converging! Dave
> > >Pete Fraser wrote: > >> "Vladimir Vassilevsky" <nospam@nowhere.com> wrote in message >> news:0Jidnc3knONVbbbRnZ2dnUVZ_oSdnZ2d@giganews.com... >> >> >>>But why would anyone want to emulate Butterworth magnitude response in a
>>>linear phase FIR filter whereas it is very straightforward to do the >>>(**exact) Butterworth as IIR filter? >> >> >> Butterworth will be one of several possible responses >> from the same hardware. >> >> I'd rather not deal with Butterworth's phase issues. >
Maybe this could help: http://www.icsi.berkeley.edu/~storn/fiwiz.html In the 'Z plane design' option, you pretty much can give it your desired magnitude response and press 'search'... At the very least, it's quite interesting to look at the genetic algorithm converging! Dave
> > >Pete Fraser wrote: > >> "Vladimir Vassilevsky" <nospam@nowhere.com> wrote in message >> news:0Jidnc3knONVbbbRnZ2dnUVZ_oSdnZ2d@giganews.com... >> >> >>>But why would anyone want to emulate Butterworth magnitude response in a
>>>linear phase FIR filter whereas it is very straightforward to do the >>>(**exact) Butterworth as IIR filter? >> >> >> Butterworth will be one of several possible responses >> from the same hardware. >> >> I'd rather not deal with Butterworth's phase issues. >
Maybe this could help: http://www.icsi.berkeley.edu/~storn/fiwiz.html In the 'Z plane design' option, you pretty much can give it your desired magnitude response and press 'search'... At the very least, it's quite interesting to look at the genetic algorithm converging! Dave
Pete Fraser wrote:

> I'd rather not deal with Butterworth's phase issues.
A good thing to remember is that any filter that is as selective as a given Butterworth filter will have a similar RMS delay spread as the Butterworth filter. So no free lunch on phase issues in many cases. Steve
"Steve Pope" <spope33@speedymail.org> wrote in message 
news:i0lfa3$rk9$1@blue.rahul.net...

> A good thing to remember is that any filter that is as > selective as a given Butterworth filter will have a > similar RMS delay spread as the Butterworth filter. > So no free lunch on phase issues in many cases.
But I'm doing a symmetric FIR with the Butterworth amplitude response.
Pete Fraser <pfraser@covad.net> wrote:

>"Steve Pope" <spope33@speedymail.org> wrote in message
>> A good thing to remember is that any filter that is as >> selective as a given Butterworth filter will have a >> similar RMS delay spread as the Butterworth filter. >> So no free lunch on phase issues in many cases.
>But I'm doing a symmetric FIR with the Butterworth >amplitude response.
Linear phase is overrated. :-) S.