简体   繁体   English

如果有两个矩阵a和b,a(b)在matlab中做了什么?

[英]If there are 2 matrices a and b, what does a(b) do in matlab?

If I have a matrix, say 如果我有一个矩阵,说

a = [1 2 3;
     4 5 6]

and

b = [2 2 2;
     3 3 3]

when I do a(b) in matlab, I get the answer as 当我在matlab中做(b)时,我得到了答案

a(b) = [4 4 4;
        2 2 2]

what exactly is happening here ? 到底发生了什么?

You're indexing a with each item in b . 您正在为b每个项目编制索引。 a(2) = 4 and a(3) = 2 a(2) = 4a(3) = 2

so 所以

c = [a(2) a(2) a(2); a(3) a(3) a(3)] 

is what you're seeing. 就是你所看到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM