Compare 2 vectors together

2 vues (au cours des 30 derniers jours)
Steven
Steven le 9 Sep 2012
Hi,
Let's say we have 2 vectors of different lenght, values (but there's not 2 values identical in the same vector) and not sorted. What's the quickest way to have all the values that are the same. For example :
a = [0 5 4 88 18 26 33]
b = [2 4 17 3 26]
c = someFunction(a,b);
==> c = [4 26];
Thank you

Réponse acceptée

Dishant Arora
Dishant Arora le 9 Sep 2012
intersect(a,b);

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