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 Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by