フィルターのクリア

Arrays sorting

1 回表示 (過去 30 日間)
athpapa -
athpapa - 2011 年 3 月 5 日
Hello,
I have 2 arrays: A=[3 5 11] and B=[2 3 0]. I multiply these 2 arrays and I produce a third: C=times(A,B)=[6 15 0]. I sort array C in descent order D=sort(C,'descend')=[15 6 0]. How can I sort and the arrays A and B to match with array D? I mean I want array A to take this order:A=[5 3 11] and array B=[3 2 0]. But, I want this function to work for random arrays and not only for the example!
Thank you...

採用された回答

Jan
Jan 2011 年 3 月 5 日
A = [3 5 11]
B = [2 3 0]
C = times(A, B);
[D, Index] = sort(C);
AA = A(Index)
BB = B(Index)
  1 件のコメント
athpapa -
athpapa - 2011 年 3 月 5 日
thank you!!

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

その他の回答 (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