필터 지우기
필터 지우기

How to rearrange/reconstruct the matrix with the indeces?

조회 수: 1 (최근 30일)
Yonghyeon Jeon
Yonghyeon Jeon 2021년 2월 17일
편집: KALYAN ACHARJYA 2021년 2월 17일
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

답변 (1개)

KALYAN ACHARJYA
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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by