Mapping between two arrays wrt one column

조회 수: 1 (최근 30일)
SANGHAMITRA MISHRA
SANGHAMITRA MISHRA 2017년 12월 25일
답변: Star Strider 2017년 12월 25일
I have two matrices: A=[1 10; 2 20; 3 30] and B=[3 1 2]'
I want this to be my final answer A=[3 30;1 10;2 20] How do I do this?

채택된 답변

Star Strider
Star Strider 2017년 12월 25일
Use ‘B’ to define the rows of ‘A’:
A=[1 10; 2 20; 3 30];
B=[3 1 2]';
Anew = A(B,:)
Anew =
3 30
1 10
2 20

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by