Compare 2 vectors together

3 visualizaciones (últimos 30 días)
Steven
Steven el 9 de Sept. de 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

Respuesta aceptada

Dishant Arora
Dishant Arora el 9 de Sept. de 2012
intersect(a,b);

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by