Borrar filtros
Borrar filtros

Finding elements common to both arrays

1 visualización (últimos 30 días)
L'O.G.
L'O.G. el 20 de Abr. de 2022
Respondida: Torsten el 20 de Abr. de 2022
Given
A = [1 2 3 6 7 9 10];
B = [4 7 8 10];
How would I determine that 7 and 10 are common to both vectors?
find(ismember(A,B))
appears to return the index of A that has the number(s) shared with B, which is not quite what I want. I want to return the values 7 and 10. How do I do that? I have very large vectors, but here I'm giving a simple example.

Respuesta aceptada

Torsten
Torsten el 20 de Abr. de 2022
Use
v = intersect(A,B)

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by