Learn MATLAB Episode 19 Convolution

In this matlab video we're going to talk about convolution. So I mentioned this before when we were talking about the low-pass filter, because they are very similar and related concepts. So, when we're talking about the low-pass filter we did a very simple filter called the moving average, and so to give you a sense of what that's doing again you're taking a window, say five samples at a time, and then you're sliding that along the signal and taking the average, and then that is the output of the filter. So this sliding motion and then applying some function to that window that's sliding along is called convolution. So what you're really doing when you're applying a filter is you're convoluting one function with another. So let's look at the definition of convolution. OK, so, convolution is also known as the star operator, and it's the integral of one function with this dummy variable. So you can see this sliding motion that i was talking about. Now this will not make a lot of sense to you if you haven't studied calculus before, but there is one important result from convolution, or the study of convolution, that we should talk about and then you should know, and that is that convolution in the time domain, and we use time as a sort of dummy variable so time to mean actual time, or time can mean space, the important distinction is that you're going from time in one domain to the frequency in the other domain, so the result that's important is that convolution in the time domain, so if I convolve one signal with another, this is equivalent to multiplication in the frequency domain. So, what is the significance of this? So that means they're two equivalent ways of computing the convolution of the signal with its filter. So one way is to just do the convolution using the formula for convolution which is herem and of course in matlab it would be a sum not an integral since we have to discretize the signals, but the other way we could do is since convolution in time is equal to multiplication in frequency, we could take the Fourier transform of both signals first, multiply them, and then do the inverse fourier transform to go back to the time domain, and so that would be equivalent to doing convolution. One application of this is the Fourier transform, or the Laplace transform, can be used to solve differential equations. So you can solve them in the frequency domain and then convert that to the time domain to get the signal of interest back. So, now again when we think about convolution a very useful analogy is this sliding motion, and so that's exactly what the moving average was doing. And so one physical manifestation of this is the blurring of an image, and so you'll see in a later lecture that I'm going to do that the blurring of an image is actually convolution, but the sliding motion you will actually do you can do by hand and it has same effect. So this is to say if you've ever used photoshop and you use the blur tool on an image, you notice that you click on the blur tool and you get a point, and then you slide it across the image on the places where you want to blur, and then it blurs those points.