finding mismatched elements ~ismember

1 visualización (últimos 30 días)
Lalit Patil
Lalit Patil el 25 de Dic. de 2012
A = [1 2 3;2 3 4;3 4 5;4 5 6;5 6 7;6 7 8;7 8 9]
B = [2 3 4;6 7 8]
flag = ~ismember(A,B,'rows');
index = find(flag);
q = A(index(flag))
The error is
??? Index exceeds matrix dimensions.
and The index finds only first elements of each row. The remaining two should also find it.. So, how to do it.?
  2 comentarios
Matt J
Matt J el 25 de Dic. de 2012
The index finds only first elements of each row. The remaining two should also find it.
This is not clear. Write explicitly what you want "index" and "q" to be.
Andrei Bobrov
Andrei Bobrov el 25 de Dic. de 2012
q = A(flag,:);
or
q = A(index,:);

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 25 de Dic. de 2012
q = setdiff(A,B,'rows')

Más respuestas (1)

Walter Roberson
Walter Roberson el 25 de Dic. de 2012
Are these integers or numbers with fractions? If they are numbers with fractions then you cannot use ismember() in most cases.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by