assign order to different vector

6 vues (au cours des 30 derniers jours)
Raphael
Raphael le 11 Juin 2012
hey
i want to determine the order of every element in a vector and apply this order to another vector. say i have a vector [0, 1, -1, 3, 5] so when ordering this vector according to its size one would have 2,3,1,4,5. So now i want to transfer this order to a second vector which is ordered by size in the following way: [10, 11, 12, 13, 14]. Applying the order of the first vector this would yield: [11, 12, 10, 13, 14]. How can this performed in matlab?
thanks for your help!
  1 commentaire
Walter Roberson
Walter Roberson le 11 Juin 2012
How do you figure that 2,3,1,4,5 is the order for [0, 1, -1, 3, 5] ?

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 11 Juin 2012
[junk, idx] = sort(A);
reordered_B = B(idx);

Catégories

En savoir plus sur Dynamic System Models dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by