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
a(b) = [4 4 4;
2 2 2]
what exactly is happening here ?
You're indexing a with each item in b
. a(2) = 4
and a(3) = 2
so
c = [a(2) a(2) a(2); a(3) a(3) a(3)]
is what you're seeing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.