Rearrange matrix rows in specific order

조회 수: 25 (최근 30일)
Jose Gloria
Jose Gloria 2021년 11월 9일
답변: C B 2021년 11월 9일
I have a matrix whose rows I would like to re-order in a specific order
e.g.,) I need the order of the rows to go from [1 2 3 4 5 6 7] to lets say [2 3 4 5 1 6 7] ?

답변 (1개)

C B
C B 2021년 11월 9일
Matrix_A = [1 1 1;2 2 2;3 3 3 ; 4 4 4; 5 5 5; 6 6 6; 7 7 7]
Matrix_A = 7×3
1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7
Inp = [2 3 4 5 1 6 7];
Output = Matrix_A(Inp,:)
Output = 7×3
2 2 2 3 3 3 4 4 4 5 5 5 1 1 1 6 6 6 7 7 7

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by