37
$\begingroup$

I'm learning DSP slowly and trying to wrap my head around some terminology:

  • Question 1: Suppose I have the following filter difference equation: $$y[n] = 2 x[n] + 4 x[n-2] + 6 x[n-3] + 8 x[n-4]$$

    There are 4 coefficients on the right-hand side. Are the "number of taps" also 4? Is the "filter order" also 4?

  • Question 2: I am trying to use the MATLAB fir1(n, Wn) function. If I wanted to create a 10-tap filter, would I set $n=10$?

  • Question 3: Suppose I have the following recursive (presumably IIR) filter difference equation: $$y[n] + 2 y[n-1] = 2 x[n] + 4 x[n-2] + 6 x[n-3] + 8 x[n-4]$$

    How would I determine the "number of taps" and the "filter order" since the number of coefficients differ on the left-hand and right-hand sides?

  • Question 4: Are the following logical if-and-only-if statements true?

    • The filter is recursive $\iff$ The filter is IIR.
    • The filter is nonrecursive $\iff$ The filter is FIR.
$\endgroup$

2 Answers 2

46
$\begingroup$

OK, I'll try to answer your questions:

Q1: the number of taps is not equal the to the filter order. In your example the filter length is 5, i.e. the filter extends over 5 input samples [$x(n), x(n-1), x(n-2), x(n-3), x(n-4)$]. The number of taps is the same as the filter length. In your case you have one tap equal to zero (the coefficient for $x(n-1)$), so you happen to have 4 non-zero taps. Still, the filter length is 5. The order of an FIR filter is filter length minus 1, i.e. the filter order in your example is 4.

Q2: the $n$ in the Matlab function fir1() is the filter order, i.e. you get a vector with $n+1$ elements as a result (so $n+1$ is your filter length = number of taps).

Q3: the filter order is again 4. You can see it from the maximum delay needed to implement your filter. It is indeed a recursive IIR filter. If by number of taps you mean the number of filter coefficients, then for an $n^{th}$ order IIR filter you generally have $2(n+1)$ coefficients, even though in your example several of them are zero.

Q4: this is a slightly tricky one. Let's start with the simple case: a non-recursive filter always has a finite impulse response, i.e. it is a FIR filter. Usually a recursive filter has an infinite impulse response, i.e. it is an IIR filter, but there are degenerate cases where a finite impulse response is implemented using a recursive structure. But the latter case is the exception.

$\endgroup$
7
  • 3
    $\begingroup$ +1: Nice answer, especially the subtle point #4. As you say, it's perfectly possible (and sometimes desirable) to write FIR filters in a recursive form. $\endgroup$
    – Peter K.
    Commented Apr 16, 2013 at 19:30
  • 1
    $\begingroup$ Regarding Q4: So are the following logical implications correct: (1) Recursive filter --> ("implies") FIR or IIR; (2) Non-recursive filter --> FIR; (3) FIR --> non-recursive or recursive (rare); (4) IIR --> recursive. Are those statements correct? $\endgroup$ Commented Apr 16, 2013 at 19:48
  • 3
    $\begingroup$ Q3: The filter order is the max. delay needed, no matter if it is needed to delay $y(n)$ or $x(n)$, so if your filter is $y(n)+y(n-10)=x(n)$ you have a filter order of 10. $\endgroup$
    – Matt L.
    Commented Apr 16, 2013 at 20:11
  • 2
    $\begingroup$ Q4: Your implications are correct. $\endgroup$
    – Matt L.
    Commented Apr 16, 2013 at 20:11
  • 1
    $\begingroup$ @engr: For window design of FIR filters it is the window that determines the filter length. You usually multiply a finite length window with an ideal (infinitely long) impulse response, and the resulting finite impulse response has the same length as the window. $\endgroup$
    – Matt L.
    Commented Jul 21, 2020 at 18:37
3
$\begingroup$
  • Question 1: The number of taps = number of coefficient s = Length of filter in case of FIR filter. The order of the filter is equal to Length of filter-1.
  • Question 2: $n$ should be set to 9 if you are using FIR filter.
  • Question 3: This is an IIR filter since you have a feed back in it. Try to convert back the equation to z-transform and and express it as a transfer function such as $$Y(z) / X(z) = H(z)$$ and then you can see what you are asking or may be read more for IIR filters to determine their order.
  • Question 4: FIR Filter is direct means it has no feedback, but for IIR filter you would have a feed back. I would suggest you to use FIR filters because they have a linear phase. On the other hand IIR filter computations are less for the same size of FIR filter, as IIR filter has less number of coefficients, but IIR filter doesn't have linear phase. So, its a trade off you can say.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.