I am using Matlab to do one of my projects. I am stuck at one basic thing.
开发者_StackOverflow中文版I have 2 matricies - A and B and a vector V. What I want to do is this:
A(i, j) = V(B(i,j)) for all i, j.
I tried doing this in the most obvious way - nested loops. For some reason, A is not getting populated. Am I missing something? Is there a more efficient (in-built function) way of doing this.
Thanks,
Anil.
If all entries in B
are integers larger than zero, and if the maximum of B
is not larger than the number of elements in V
, then you can simply write
A = V(B);
精彩评论