MATLAB Answers

Vectorization of product of flipped vectors

1 view (last 30 days)
Tétef on 22 Feb 2013
I'm looking for how to vectorize this loop :
for i=1:length(r1);
r1 and r2 are two vectors of the same size.

Accepted Answer

Teja Muppirala
Teja Muppirala on 22 Feb 2013
Faster for long vectors, slower for short ones:
r = conv(r1,r2);
r = r(1:numel(r1));

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!