Vectorization of product of flipped vectors
1 次查看(过去 30 天)
显示 更早的评论
I'm looking for how to vectorize this loop :
r=zeros(1,length(r1));
for i=1:length(r1);
r(i)=sum(r1(1:i).*r2(i:-1:1));
end
r1 and r2 are two vectors of the same size.
0 个评论
采纳的回答
Teja Muppirala
2013-2-22
Faster for long vectors, slower for short ones:
r = conv(r1,r2);
r = r(1:numel(r1));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!