sorting 2 array based on elements of other array

1 回表示 (過去 30 日間)
Niharika  Nayak
Niharika Nayak 2020 年 1 月 3 日
回答済み: Vladimir Sovkov 2020 年 1 月 3 日
I have two arrays A and B
A=[0.1639,0.2123,0.1697];
B=[c1,c2,c3];
I want sort array B according to array A
my expected output like that
A=sort(A) which gives
A=[0.1639 0.1697 0.2123]
and as per A
B should be like this
B=[c1,c3,c2];
plz help me

採用された回答

Vladimir Sovkov
Vladimir Sovkov 2020 年 1 月 3 日
[A,ind]=sort(A);
B=B(ind);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by