An example showing how convolution is just a dot product: Difference between revisions
Jump to navigation
Jump to search
(Created page with "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. <nowiki> funct…") |
No edit summary |
||
Line 12: | Line 12: | ||
x=h; |
x=h; |
||
h=temp; |
h=temp; |
||
end |
|||
for n = Order : NoOfData |
for n = Order : NoOfData |
||
D = x(n:-1:n-Order+1); |
D = x(n:-1:n-Order+1); |
||
y(n) = h*D' ; % Convolution |
y(n) = h*D' ; % Convolution |
||
end |
end |
||
end |
|||
</nowiki> |
</nowiki> |
Latest revision as of 13:09, 4 December 2013
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