Electronic – Basic FIR Filter Question

fir

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?

Best Answer

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]