2

We've just started learn about FIR filters in my DSP class. The homework question is:

A particular FIR filter has coefficients {b(k)} = {3, 4, -4, -3} for k = 0, 1, 2, 3. Give the output y[n] when the input is x[n] = δ[n].

Am I correct that the outputs should be:

y[0] = 3 y[1] = 0 y[2] = 0 y[3] = 0?

whimsey
  • 21
  • 1
  • 2
    No, that is not correct. Show your work :) – pgvoorhees Oct 11 '16 at 22:45
  • I guess that's the problem. I don't know what the work is supposed to be. δ[n] is 1 when n = 0, and 0 for all other values of n. δ[n] is the impulse, and becomes the impulse response, h[n]. y[n] = b(k)h[k]. I thought. :/ – whimsey Oct 11 '16 at 23:09
  • Impulse response, yes. But the impulse response is the convolution, which is not the operation you performed. – alex.forencich Oct 11 '16 at 23:27
  • 3
    No, wait, nevermind, I think I found it. it should be y[n] = b(k)x[n-k], so correct outputs should just be the coefficients {b(k)}. – whimsey Oct 11 '16 at 23:28
  • Not quite, but you are closer. You're missing one last thing. Check the definition of FIR: https://en.wikipedia.org/wiki/Finite_impulse_response#Definition – pgvoorhees Oct 12 '16 at 00:31
  • Is it the summation? I thought that was only necessary for convolution? In that case, does it make the outputs y[0] = 3, y[1] = 7, y[2] = 3, y[3] = 0? The thought process here is that: y[0] = 3x[0-0], y[1] = 4x[1-1] + 3x[0-0], y[2] = -4x[2-2] + 4x[1-1] + 3x[0-0], y[3] = -3x[3-3] + -4x[2-2] + 4x[1-1] + 3x[0-0] – whimsey Oct 12 '16 at 00:43
  • I'm sorry, I misread your last comment. You were correct earlier. The answer in just the coefficients of B(k). – pgvoorhees Oct 12 '16 at 11:15

1 Answers1

1

Late, but maybe it can still help someone: it's the same as multiplying two numbers, but instead of carry, you use the same place for the whole resultant number, with the length of the result being length(first)+length(second)-1.

Ex.: 14 and 23, both length 2 => final length is 2 + 2 - 1 = 3. Normally, 14*23 = 14*3 + 14*20, but the first number results in a carry: 14*3 = 4*3 + 10*3 = 42. In convolution, you treat 4*3 not as 2 carry 1, but as 12, a number that occupies the same place as a digit. Which means that the first number would be: [3, 12], and the second would be [2, 8, 0] (shifted one digit). And now you just add them, place by place: [2, 8+3, 12+0] = [2, 11, 12].

If it helps, here's how it would look like in C/C++, considering the first vector to be a, the second b, and the output y:

for(int i=0; i<a.size(); ++i)
    for(int j=0; j<b.size(); ++j)
        y[i+j] += a[i]*b[j];

As you can see, it takes the first element of the first vector (the "digit" place) and multiplies it, sequentially, with each element of the 2nd. Then it increments, the 2nd element is multiplied with each element of the 1st vector, and so on.

For your case, you convolve with the dirac signal, thus a 1 (maybe zero padded, depends on how long you want the signal to be). Any number multiplied with 1 is itself, so you were right in your comment. If you had, for example, a 2 sample input like [2, 5], and the result would have been:

     [3,   4,  -4,  -3] *
               [2,   5] =
-----------------------
    [15,  20, -20, -15] +
[6,   8,  -8,  -6,   0] =
-----------------------
[6,  23,  12, -26, -15]
a concerned citizen
  • 21,167
  • 1
  • 20
  • 40