What is the method for generating coefficients for the Farrow structure in Matlab? I am designing a low pass filter using firpm
, but the output of the Farrow structure is not delayed.
-
1$\begingroup$ I'm not sure what you want to achieve. The Farrow structure is basically an implementation of an adjustable FIR filter. Often the adjustable parameter is a fractional delay, but that's not necessary. If you have designed a fixed FIR filter there is no standard way to convert it to a Farrow structure. Which parameter should be adjustable? $\endgroup$– Matt L.Commented Nov 17, 2015 at 17:33
3 Answers
The farrow structure effectively interpolates between different sets of filter coefficients, so if you need an adjustable delay ($\delta$) of, say, 0 to 1 samples, you need to create a number (K) of FIR filters covering that delay interval. The matlab command then creates a $ K-1^{th} $ order polynomial in $ \delta $ to represent each filter coefficient.
As Matt L said, if you don't need an adjustable delay, or to interpolate between filter coefficients based on some other parameter, there's no need for the farrow structure. If, however, you're just interested in how to get from FIR coefficients to farrow structure coefficients in general, I can post some rough code as I was messing about with this the other day. (hint: it's just simple least squares fitting).
I wrote a Python script to generate the coefficients for FIR sections of Farrow structure:
from sympy import *
N = 3
h = [1]*(N+1)
Delta = symbols('Delta')
for k in range(N+1) : h = [h[m] if m==k else h[m]*(Delta-k)/(m-k) for m in range(N+1)]
Cs = [Poly(h[m], Delta) for m in range(N+1)]
C = [Cs[m].all_coeffs() for m in range(N+1)]
The code is really simple, it calculates the coefficients of Lagrange interpolation polynomial for a given $\Delta$ and rearranges each coefficient as a polynomial of $\Delta$ and extracts the coefficients. For $N=3$, \begin{equation*} C_s = \left[\frac{1}{6} (-\Delta+1)(\Delta-3)(\Delta-2), \quad \frac{\Delta}{2} (\Delta - 3) (\Delta - 2), \quad - \frac{\Delta}{2} (\Delta - 3) (\Delta-1), \quad \frac{\Delta}{6} (\Delta-2) (\Delta-1) \right ] \end{equation*} and
$ C = [[-1/6, 1, -11/6, 1], [1/2, -5/2, 3, 0], [-1/2, 2, -3/2, 0], [1/6, -1/2, 1/3, 0]]$
I don't have MATLAB symbolic toolbox, but it shouldn't be hard to convert this code to MATLAB code. Please note that this is an indirect way of calculating the coefficients, there is probably a close-from expression but didn't really care as I always implement my Farrow structure for N=3 or N=4.
Ref : Lagrange Interpolation
If you are using a Farrow structure for resampling or interpolation, one way of looking at it is as the sum of multiple polynomial evaluation structures, where each polynomial is fit to a portion of the impulse response of the low-pass filter function (for example, a polynomial fit to each sub-section or lobe of a windowed Sinc, which the first few lobes of a firpm impulse response may resemble at sufficient resolution).