Borrar filtros
Borrar filtros

How to compare an array with 2D matrix?

3 visualizaciones (últimos 30 días)
Emmanuel
Emmanuel el 21 de Oct. de 2016
Comentada: Emmanuel el 21 de Oct. de 2016
If I have an array A= [1,2] and matrix B= [3,4;8,6;1,2], How can I say that array A is present in B?

Respuesta aceptada

KSSV
KSSV el 21 de Oct. de 2016
doc ismember
  1 comentario
Emmanuel
Emmanuel el 21 de Oct. de 2016
Thanks a lot! It works!! You are very helpful

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 21 de Oct. de 2016
Try ismember() with the 'rows' option:
[~, matchingRows] = ismember(A, B, 'rows')
  3 comentarios
Image Analyst
Image Analyst el 21 de Oct. de 2016
Emmanuel, try this:
A= [1,2]
B= [3,4;8,6;1,2; 4,5; 1,2]
[inA, inB] = ismember(B, A, 'rows')
matchingRows = find(inB)
Emmanuel
Emmanuel el 21 de Oct. de 2016
Yeah! That works. Thank you very much..

Iniciar sesión para comentar.

Categorías

Más información sobre Multidimensional Arrays 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