开发者

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

开发者 https://www.devze.com 2023-02-14 01:31 出处:网络
I am using Matlab to do one of my projects. I am stuck at one basic thing.开发者_StackOverflow中文版

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

精彩评论

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