필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by