How to rearrange/reconstruct the matrix with the indeces?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have at sample matrix
A = [ 11, 12 ; 21, 22 ; 31, 32 ; 41, 42];
and index matrix
Idx = [ 2 2 ; 1 2 ; 3 4 ; 4 1];
I want to rearrange the matrix A to
RA = [ 12, 22 ; 11, 22 ; 13, 24 ; 14 , 21];
This result means that the first columnn of the matrix RA is rearrange of the first columnn of the matrix A by the first column of the index matrix Idx
and
the second columnn of the matrix RA is rearrange of the second columnn of the matrix A by the second column of the index matrix Idx
댓글 수: 0
답변 (1개)
KALYAN ACHARJYA
2021년 2월 17일
편집: KALYAN ACHARJYA
2021년 2월 17일
"This result means that the first columnn of the matrix RA is rearrange of the first columnn of the matrix A by the first column of the index matrix Idx";
and
"the second columnn of the matrix RA is rearrange of the second columnn of the matrix A by the second column of the index matrix Idx:
Doubt: I have doubt between text description and RA result, maybe I'm wrong?
A = [ 11, 12 ; 21, 22 ; 31, 32 ; 41, 42]
Idx = [ 2 2 ; 1 2 ; 3 4 ; 4 1]
my_RA=[A(Idx(:,1),1),A(Idx(:,2),2)]
your_RA= [ 12, 22 ; 11, 22 ; 13, 24 ; 14 , 21]
Result:
A =
11 12
21 22
31 32
41 42
Idx =
2 2
1 2
3 4
4 1
my_RA =
21 22
11 22
31 42
41 12
your_RA =
12 22
11 22
13 24
14 21
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!