How do i sort table rows based on other table rows ?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ahmed obaid
le 8 Juin 2017
Réponse apportée : Andrei Bobrov
le 8 Juin 2017
Dear experiences..
i have two tables.. A and B..
where table A involves ( id, num, var1 , var2).., and table B involves (num, var1.....varn).. i need to sort either table A rows based on table B num order or vise versa... how do i perform this task ?
thanks
0 commentaires
Réponse acceptée
Plus de réponses (1)
Guillaume
le 8 Juin 2017
sorting A according to B:
[isinB, whereinB] = ismember(tableA.num, tableN.num);
assert(all(isinB), 'some rows of A are not found in B);
[~, order] = sort(whereinB);
sortedtableA = tableA(order, :);
0 commentaires
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!