Arrange element according to its index

11 ビュー (過去 30 日間)
Rendy Dalimunthe
Rendy Dalimunthe 2015 年 8 月 2 日
コメント済み: Rendy Dalimunthe 2015 年 8 月 2 日
Hi All,
Let's say we have arrays as follow: a=[3 4 5 6 7 9] b=[2 4 1 3 5 6]
in this case b acts as index of a. I want to form a new element x such that: x=[5 3 6 4 7 9] in which a is being arranged according to its index.
How can I do that? Appreciate your help.

採用された回答

Stephen23
Stephen23 2015 年 8 月 2 日
Easy:
>> a = [3,4,5,6,7,9];
>> b = [2,4,1,3,5,6];
>> x(b) = a
x =
5 3 6 4 7 9
  1 件のコメント
Rendy Dalimunthe
Rendy Dalimunthe 2015 年 8 月 2 日
thank you very much, this is brilliant

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by