vector - vectorize lookup in matlab 2-d matrix -
hi having trouble @ vectorizing following matlab code segment
for i=1:n; vec(i) = mat(index(i),i); end; where index permutation of 1:n.
code slow in form. have checked notes on vectorization tricks in matlab no avail might missing obvious. in advance!
you can use index , 1:n relevant parts of mat.
vec = mat(index, 1:n); if n number of columns in mat, can do:
vec = mat(index,:);
Comments
Post a Comment