Hi,
I want to address your post in two parts. Let me summarize first and
then go into a little more detail.
Bottom line:
CREMEZ can be used to design nonlinear phase filters as stated in the
description of the function. However, it will probably not be useful for
what you want.
On the other hand, your expectation of getting better performance from
an FIR filter if you remove the linear-phase requirement is correct and
there are tools from The MathWorks -specifically in the Filter Design
Toolbox- to address this.
Details:
First let me address the concern on CREMEZ not being able to design
nonlinear phase filters.
This can indeed be done, what needs to be done is use the delay
parameter in the response to reduce the group delay compared to a linear
phase design.
In your example:
b1 = 1000*cremez(7,edge,'lowpass',weight);
Which produces, as you mentioned, a linear phase filter with group delay
of 3.5 samples.
If you specify a negative delay parameter (an advance effectively) like:
b2 = 1000*cremez(7,edge,{'lowpass',-2},weight);
The group delay is clearly not flat, thus the phase is nonlinear. The
group delay tends to be about 1.5 (3.5+(-2)) in the passband of the
filter. The impulse response is obviously no longer symmetric.
Unfortunately, this reduced passband group delay comes at the expense of
decreased passband/stopband performance in the magnitude response. Which
is the opposite of what you are looking for if I understand correctly.
What you are looking for can be achieved by using design functions
available in the Filter Design Toolbox.
For instance, if you allow for even-ordered filters, if we compare these
2 designs:
b1 = remez(8,edge,[1 1 0 0],weight);
b2 = gremez(8,edge,[1 1 0 0],weight,'minphase');
The nonlinear phase (minimum-phase) filter b2 has a better stopband
attenuation (about 22 dB as opposed to just over 16 db) and less
passband peak ripple (about 0.0014 dB compared to about 0.013 dB).
This is probably the way to go for equiripple designs if eve-ordered
filters are ok.
If you absolutely need odd-order, or if you want to optimize for another
norm, like a least-squares optimization, or a 4-norm, 8-norm, etc, it is
best to use FIRLPNORM. For example:
b1=remez(7,edge,[1 1 0 0],weight);
b2=firlpnorm(7,edge,edge,[1 1 0 0],[100 100 1 1]);
In this case b2 has a stopband attenuation of about 24.48 dB as opposed
to 16.87dB and a passband peak ripple of about 0.0052 dB as opposed to
0.013 dB.
Finally, for a least squares response. If you compare:
b1=firls(7,edge,[1 1 0 0],weight);
b2=firlpnorm(7,edge,edge,[1 1 0 0],[10 10 1 1],[2 2]);
b2 will definitively have a smaller mean squared error than b1.
Hope this helps,
Ricardo.
Paul Mennen wrote:
> Trying to design an FIR Low pass filter.
> As a simple example, consider:
>
>
>>>edge = [0 .3 .7 1];
>>>weight = [100 1];
>>>1000*remez(7,edge,[1 1 0 0],weight)
>
> ans= 32.2690 -109.2208 81.9170 495.0689 495.0689 81.9170 -109.2208 32.2690
>
> The resulting filter has a pass band ripple of +/- .013dB
> and a stop band of -16.84dB. (The pass band is from DC to .3
> and the stop band is from .7 to 1 where 1 represents Fs/2).
>
> Note that the impulse response is symmetric so this is a linear phase
> filter. This is expected because that is what REMEZ advertises itself
> as doing.
>
> However I know I can get better performance by removing the linear
> phase restriction. So now I try:
>
>
>>>1000*cremez(7,edge,'lowpass',weight,'real')
>
> ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466
>
>
>>>1000*cremez(7,edge,'lowpass',weight,'even')
>
> ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466
>
> Note that both of these responses are just about exactly the
> same answer as given by REMEZ.
>
> From the help message (help cremez):
> REMEZ Complex and nonlinear phase equiripple FIR filter design.
>
> Yet I see only linear phase filters coming out of cremez.
> Isn't this false advertising? (I tried 'none' for the symmetry
> argument, but a complex filter comes out - clearly not what
> I am looking for.)
>
> The reason that I know that one can do much better than cremez
> is that by trial and error I came up with a filter with this
> impulse response:
>
> p = [307 535 307 -92 -113 43 29 -16];
>
> I plotted the result with: plot(20*log10(abs(freqz(p,1,1000))));
>
> Note the passband ripple is +/-.0126 dB (slightly better than before)
> and the stopband is -24 dB (much better than before!). Clearly
> not linear phase since it is not symmetrical, but I don't care
> about that.
>
> Any ideas why my trial and error approach does so much better
> than cremez?
>
> Any ideas on how to design such FIR filters without trial and error?
> I thought of using yulewalk, but that has some problems. Yulewalk
> is for iir filters, so right there it is at least twice as complicated
> as it should be. Also Yulewalk minimizes in the least squares sense
> and so it won't necessarily minimize the max deviation from desired.
> And finally Yulewalk doesn't allow a weighting function.
>
> ~Paul Mennen
>