Filter löschen
Filter löschen

Arrays sorting

1 Ansicht (letzte 30 Tage)
athpapa -
athpapa - am 5 Mär. 2011
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...

Akzeptierte Antwort

Jan
Jan am 5 Mär. 2011
A = [3 5 11]
B = [2 3 0]
C = times(A, B);
[D, Index] = sort(C);
AA = A(Index)
BB = B(Index)
  1 Kommentar
athpapa -
athpapa - am 5 Mär. 2011
thank you!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by