# Designing an FIR filter in Matlab with differing number of precursor taps and postcursor taps

I'm trying to fit an FIR filter to the measured frequency response (magnitude and phase) of a device. The frequency response is essentially a low-pass filter. I'd like to vary the number of taps to see how many are necessary to appropriately match the response, but also give differing number of precursor and postcursor taps in the design.

I've investigated Matlab's fdesign.arbmag and fdesign.arbmagnphase functions, but these seem to only give designs with the same number of pre- and post-cursor taps.

Here's some sample code with simplified frequency (F) and amplitude (A) values for reference.

F = 0:0.1:1;
A = [1 0.85 0.9 0.7 0.5 0.3 0.35 0.1 0.2 0.1 0];
filterOrder = 7;

d = fdesign.arbmag('N,F,A',filterOrder,F,A);
Hd = design(d);
fvtool(Hd)
tapWeights = [Hd.numerator];
disp(tapWeights)


The above code runs happily, and produces a low-pass filter that matches the frequency response reasonably well, with tap weights as follows:

[0.0030  0.0361  0.2161  0.4500  0.2161  0.0361  0.0030].


However, the central tap (the cursor, 0.45) is surrounded by three precursor and three postcursor taps. Is there a way to design, say, with one precursor and six postcursors.

## 1 Answer

There is no reasonable way to explicitly choose the number of taps before and after the peak. The reason is simple: the arbitrary magnitude response design results in a linear phase, and, consequently, the impulse response is symmetrical. If you specify a desired complex frequency response in terms of magnitude and phase, the location of the peak is an outcome of the design process. The smaller the average delay (implicitly specified by the desired phase response), the further to the left the peak will occur.

Take as an example the design of an FIR low pass filter with $$21$$ taps. The figure below shows $$3$$ designs. The difference is the desired phase response. The top figure shows the impulse response (filter taps) for a linear desired phase response, the middle one for a non-linear phase response with a lower pass band delay than the linear phase response, and the bottom figure shows the impulse response of the corresponding minimum phase filter. The location of the peak is entirely determined by the specified phase response.

• Thanks for the very clear reply! I have a follow-up question on this, if you don't mind. For hardware implementations of feed-forward equalisation (FIR filters) for optical communication systems, it's not uncommon to see see more precursor taps than postcursor taps, or in simple cases just one precursor tap on its own with the main tap to form a high-pass filter. For that single postcursor tap case, can you suggest a method for fitting it to a given frequency response? – bth-root Jun 25 '19 at 19:58