sorting vectors
Afficher commentaires plus anciens
To anyone out there who can help!
This seems to be an easy enough problem however I cannot seem to figure it out..
I have two vectors x=[25,69,45,53] y=[160,201,199,450]
I want to have an output that will sort x from smallest to largest and then display its corresponding y values..if that doesn't make sense I am trying to get a result thatlooks like this y=[160,199,450,201]
Réponses (1)
Teja Muppirala
le 3 Mai 2011
Call sort with a second output argument.
x=[25,69,45,53];
y=[160,201,199,450];
[xsorted, I] = sort(x)
ysorted = y(I)
1 commentaire
Erick
le 3 Mai 2011
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!