Convolution using non-constant kernel?
3 views (last 30 days)
Show older comments
Is there a faster way of performing convolution using a non-constant kernel than with a loop? The kernel contains values completely independent from those in the first vector.
I have been able to achieve what I need by code similar to what follows, but it is being run millions of times and I would love to optimize it, if possible.
rng(42);
nr = 100000;
A = rand(nr,1);
B = rand(nr,1);
w = 100; % window length
D = NaN(nr,1); % initialize results vector
for i = w:nr
D(i) = A((i-w+1):i)' * B((i-w+1):i);
end
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!