Sorting values according to index
37 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two vales
S=[70 110 65 30 25 40 60]
K=[4 2 3 1 5 7 6];
I have to sort S according to K for example 70 must be 1n 4th position 110 must be in 2nd position ,so on
X=[30 110 65 70 25 60 40],please assist
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 29 Nov 2012
Modifié(e) : Azzi Abdelmalek
le 29 Nov 2012
S=[70 110 65 30 25 40 60]
K=[4 2 3 1 5 7 6];
[~,idx]=sort(K);
out=S(idx)
6 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!