フィルターのクリア

n=A(B) where A and B are matrices?

1 回表示 (過去 30 日間)
Abhijith
Abhijith 2013 年 8 月 19 日
Hello, I just tried to do the following operation,
>> B=full(B)
B =
5 1 8 3 2 8
9 9 8 8 3 6
1 1 1 4 2 5
4 7 4 9 2 2
>> A=full(A)
A =
1 8 2 6 5 9
4 3 6 7 1 2
2 5 3 7 3 8
>> A(B)
ans =
3 1 6 2 4 6
3 3 6 6 2 5
1 1 1 8 4 3
8 2 8 3 4 4
I would like to know what exactly has happened here. Thank you.

採用された回答

David Sanchez
David Sanchez 2013 年 8 月 19 日
A(B) returns the value of the B(ith) element of A. The elements are counted column-wise, what means than in your case: A(1) = 1; A(2) = 4; A(3) = 2; A(4) = 8; A(5) = 3; ... A(18) = 8;
Now, if you take the matrix B as index, you get back a matrix whose elements are the elements of A in the position determined by the value of the element of B:
B(1) = 5
then, the first element of A(B) = A(5) = 3.
B(2) = 9
then, the second element of A(B) = A(9) = 3
B(3) = 1
then, the second element of A(B) = A(1) = 1
and so on.
  1 件のコメント
Abhijith
Abhijith 2013 年 8 月 19 日
Thank you for your answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by