# FIR filter with relaxed transition band

Is there a way to design a lowpass FIR filter with a more relaxed transition band than what MATLAB FilterDesigner tool generates? What I intend to do is to reduce number of taps needed to implement the filter. The response that MATLAB generates is good but it needs too much coefficients and the response that I need can be relaxed in the almost second half of the transition band.

The spec. of the desired filter is as below:
Fpass = 5 M;
Rejection at 700k offset from band edge: 15 dB
Rejection at 1.5M offset from band edge: 30 dB
Rejection at 5.5M offset from band edge: 70 dB

Here are the parameters I have used (Units are MHz and dB).
Fs = 187.5; Fpass = 5;
Fstop = 10.5;
Apass = 0.35;
Astop = 70;
Other parameters are method = equiripple and density factor = 20;

Though the resulted filter has 70dB rejection at 10.5 M, I doesn't have the rejections needed at 700k and 1.5M offsets. To get that 15 dB rejection I have to either increase rejection at stopband or decrease Fstop which will result in more coefficients and is overkill for rest of the filter.

Also tried firpm() and using the parameters below I got the same response as the one by FiterDesigner which didn't help.

>> [n,fo,ao,w] = firpmord([5e6 10.5e6],[1 0],[0.01 0.0002],187.5e6);
>> b = firpm(n,fo,ao,w);
• how are you designing this? Usually, the transition width is what you define, and Matlab just does what you say. There's many ways to design a filter in matlab, so it's not clear how you're doing it, currently. – Marcus Müller Jun 27 '20 at 15:54
• The one in the image has been designed with filterDesigner, using equiripple method – Laleh Jun 27 '20 at 18:52

[n,fo,ao,w] = firpmord([5e6 10.5e6],[1 0],[0.01 0.0002],187.5e6);

You've specified that your filter has at least 37 dB attenuation in the transition width of 5.5 MHz, which is less than $$\frac1{34}$$ of the sampling rate.

Rule of Thumb says your filter length should be about

$$N\approx \frac 23 \log_{10} \left[\frac1{10 \delta_1\delta_2}\right]\,\frac{f_s}{\Delta f}\text,$$

i.e. something like 2/3·log(1/(10·10⁻²·10⁻⁴))·34~=22·5~=110, or a little less. I don't have matlab on this computer, but I'd bet I'm close.

(how is 100 taps even a problem if you want a 1/34 band transition width?)

So, that's how relaxed you are letting things be. firpmord gives you the least order of filter that's possible while still attaining these specs. If you want a more relaxed design, you need more relaxed specifications.

However, why are you even specifying it like this? Rather than using such a strict tolerance at a single frequency with an attenuation that's impossible, you should be trying to specify the attenuation you want in the stop band, and just relax the tolerance greatly for points in the transition width.

Also, this design method is simply not the right approach. Instead, try a window filter design approach.

• Why do you say this isn’t the right approach and that windowing would be better? The only utility I found for windowing is when you don’t have the resources to compute the filter coefficients. The right approach in my opinion would be to course filter decimate and fine filter using firls() – Dan Boschen Jun 30 '20 at 10:37
• (Coarse Filter meaning a filter with a wider transition band... not course filter whatever that might be) – Dan Boschen Jun 30 '20 at 18:49
• That's true. If you can, always use the optimized approach, but if your constraint is "I want to have an exactly N samples long impulse response, and I've got a rough idea of what things should look like", then window filter design would be a quick way to get there. – Marcus Müller Jun 30 '20 at 18:51
• True dat- quick and easy. And as Matt L had pointed out in the post where we explored that the Kaiser window can get you most of the way there – Dan Boschen Jun 30 '20 at 18:57

Instead of using the FilterDesigner Tool consider using the firls() and firpm() commands directly since they will return optimized filters (in the least squares sense or peak error /equiripple sense respectively) very easily with one MATLAB command. Type help firls or help firpm in MATLAB to read further documentation on how to use these and specifically how the parameters define the transition bandwidth desired.

This can equally be done through the FilterDesigner but I see no need for that added complexity.

• For extra credit, familiarize yourself with the underlying math. There seem to be a lot of Matlab button-pushers out there that don't know the mechanisms behind the buttons -- that's not going to lead to the best possible designs. – TimWescott Jun 27 '20 at 18:33
• Is there any difference in the result when using commands directly? I tried firpm() and the number of taps didn't get better. – Laleh Jun 27 '20 at 18:51
• @Laleh again, you forgot to tell us how you used firpm. As it can design pretty arbitrary filters, I'd say you're simply not using it correctly! – Marcus Müller Jun 27 '20 at 20:48
• @Laleh I suspect the issue must be with your use of normalized frequency. With firpm the stop band will absolutely start with the point of constant ripple such as the 10MHz location in your plot. Look carefully at the documentation for firpm. If you add the specific command you used and how you came up with the pass band and stop band values we may be able to help further. – Dan Boschen Jun 27 '20 at 20:53
• @DanBoschen I have updated the question and included the desired spec. for the filter. – Laleh Jun 28 '20 at 17:25