function opposite of ismember?

Hi, Is there a function that does the opposite of 'ismember' i.e. something like, 'isnotmember'?
So if:
A = [1:10]
B = [2,5,7]
ismember(A,B)
ans =
0 1 0 0 1 0 1 0 0 0
But instead, I want
isnotmember(A,B)
ans =
1 0 1 1 0 1 0 1 1 1

 Respuesta aceptada

Matt Fig
Matt Fig el 8 de Ag. de 2012
Editada: Matt Fig el 8 de Ag. de 2012

4 votos

Use the logical negation symbol
~ismember(A,B)
or the functional form:
not(ismember(A,B))

4 comentarios

S
S el 8 de Ag. de 2012
Hi Matt, thanks for the quick reply.
The solution was easier than I thought...
Regardless, thanks! I really appreciate it.
Lalit Patil
Lalit Patil el 25 de Dic. de 2012
A = [1:10];
B = [2,5,7];
[flag,index] = ismember(B,A);
v = A(index(flag))
I tried and find that i am able to find flag and index of ismember(B,A) function.
But, i can not find for ~ismember(A,B) and not(ismember(A,B))
So, how to find it..?
Andrei Bobrov
Andrei Bobrov el 25 de Dic. de 2012
Editada: Andrei Bobrov el 25 de Dic. de 2012
flag = ~ismember(B,A);
index = find(flag);
or
[out,index] = setdiff(A,B);
Lalit Patil
Lalit Patil el 25 de Dic. de 2012
Editada: Lalit Patil el 25 de Dic. de 2012
It works by
flag = ~ismember(A,B);
index = find(flag);
Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

S
S
el 8 de Ag. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by