# An example showing how convolution is just a dot product

From Class Wiki

This example shows how each point of a numerical convolution is just an inner (or dot) product. It is suitable as a starting point for an adaptive filter script.

function y = my_convolution(h,x) % This function does convolution of a sequence x, with a set of FIR filter coefficients, h. % It ignores the first points (length of the shorter vector) in the output. % So the output is abs(lenght(x)-length(h)) % h and x are assumed to be row vectors. Order = length(h); NoOfData = length(x); if (Order > NoOfData) temp=x; %Swap the x and h, because x*h = h*x and we need Order < NoOfData x=h; h=temp; end for n = Order : NoOfData D = x(n:-1:n-Order+1); y(n) = h*D' ; % Convolution end end