Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Daniel
Posts:
12
Registered:
9/29/12


How to vectorize this matrix indexing
Posted:
Dec 28, 2012 8:14 AM


Hello,
Does anyone have an idea on vectorizing the for loop in the following program?
A=rand(10,4) b=[2 4 1 3 2 3 1 2 4 1]' r=zeros(10,1);
for m=1:10 r(m)=A(m,b(m)); end
'b' is an index array for selecting a certain column. The index is different for different rows. Any suggestions? Thanks.
Daniel



