help understanding simple Vectorization
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am new to vectorization and would appreciate if someone could help me vectorize the following;
for i = 1: length(A)
idx = A(i,1);
C(i) = A(i,1)*B(idx);
end
1 个评论
Fangjun Jiang
2011-8-6
Please provide an example data. Sometimes the size (of the data) does matter.
采纳的回答
Fangjun Jiang
2011-8-6
C=A(:,1).*B(A(:,1))
3 个评论
Paulo Silva
2011-8-6
I tried and it gave the same result as your code, like Fangjun said you should provide one example for us to test.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!