Sort rows of matrix by matching column with another matrix column

5 vues (au cours des 30 derniers jours)
John Hernandez
John Hernandez le 10 Fév 2020
Commenté : John Hernandez le 11 Fév 2020
Hello All!
So I have two matrices, both the same size (88 rows and 31 columns).
In one matrix (A), I have the row data sorted in descending order based off of columns 28, 29 and 30 and in column 31 I have the identifiers for each individual.
In matrix B, I want to sort rows so that all of column 31 identifiers match column 31 of matrix A.
I'm more than happy to give an example, but the data set is pretty large and didn't want to copy and paste.

Réponse acceptée

James Tursa
James Tursa le 10 Fév 2020
E.g., assuming everything in column 31 has a match
[~,x] = ismember(A(:,31),B(:,31));
Bsort = B(x,:);
  1 commentaire
John Hernandez
John Hernandez le 11 Fév 2020
Thank you!! I will try this out later and let you know but it should work. :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices 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