help understanding simple Vectorization
1 view (last 30 days)
Show older comments
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 Comment
Fangjun Jiang
on 6 Aug 2011
Please provide an example data. Sometimes the size (of the data) does matter.
Accepted Answer
Fangjun Jiang
on 6 Aug 2011
C=A(:,1).*B(A(:,1))
3 Comments
Paulo Silva
on 6 Aug 2011
I tried and it gave the same result as your code, like Fangjun said you should provide one example for us to test.
More Answers (0)
See Also
Categories
Find more on Dynamic System Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!