Borrar filtros
Borrar filtros

Arrays sorting

1 visualización (últimos 30 días)
athpapa -
athpapa - el 5 de Mzo. de 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...

Respuesta aceptada

Jan
Jan el 5 de Mzo. de 2011
A = [3 5 11]
B = [2 3 0]
C = times(A, B);
[D, Index] = sort(C);
AA = A(Index)
BB = B(Index)
  1 comentario
athpapa -
athpapa - el 5 de Mzo. de 2011
thank you!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by