find dublicated value in a column and return the whole row

1 vue (au cours des 30 derniers jours)
Martin
Martin le 22 Oct 2018
Commenté : madhan ravi le 22 Oct 2018
imagine I have this:
A = [ 1 ; 3 ; 5 ; 6 ; 9 ]
and
B = [ 1 4 ; 2 7 ; 3 5 ; 9 10 ]
I need to end up with:
C = [ 1 4 ; 3 5 ; 9 10 ]
In B(:,1) column I need to find those from A that match, and if so, return the full rows of B. Hope I am clear

Réponse acceptée

madhan ravi
madhan ravi le 22 Oct 2018
A = [ 1 ; 3 ; 5 ; 6 ; 9 ]
B = [ 1 4 ; 2 7 ; 3 5 ; 9 10 ]
idx=ismember(B(:,1),A)
C = B(idx,:)
  3 commentaires
Martin
Martin le 22 Oct 2018
thanks bro
madhan ravi
madhan ravi le 22 Oct 2018
Anytime :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB 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!

Translated by