## Matlab ConvolutionThis is a quick look at convolution and deconvolution in matlab. First you might have wondered, as I have, what's the deal with flipping the filter? It's really simple if you just think about the physical phenomenon. Suppose you have a filter modeling what a circuit or room does to an electric or acoustic signal. Picture the wave hitting the filter. Does the back of one hit the front of the other first? No! They first touch head-to-head (first sample to first sample). The only way to get that behaviour is by either flipping the filter or the signal. I'm not going to write the definition of convolution. I'm sure you've seen it. I'll just put the discrete example here. h = [1 2 3] x = [4 5 6] 4 5 6 ------- 3 2|1 |4 <- first output 3|2 1 |13 |3 2 1|28 <- last output for filter | 3 2|27 | 3|18 <- last output for conv c = conv(h,x) -> [4 13 28 27 18] filter(h,1,x) -> [4 13 28]
And the last two values, [27 18], are in the filter delay line. You're probably also familiar with the polynomial multiplication trick. This procedure turns out to be the same way you multiply polynomials. (1x^2+2x^1+3x^0)*(4x^2+5x^1+6x^0) -> (1*4)x^4+(1*5+2*4)x^3+(1*6+2*5+3*4)x^2+(2*6+3*5)x^1+(3*6)x^0 -> 4x^4+13x^3+28x^2+27x^1+18*x^0
Similarly, you can do polynomial division using deconv. If you take a
look at the matlab deconv function (type deconv), it implements deconv
using filter. |