开发者

Matlab: how to apply point-wise function on a matrix?

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜