function opposite of ismember?

60 vues (au cours des 30 derniers jours)
S
S le 8 Août 2012
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

Réponse acceptée

Matt Fig
Matt Fig le 8 Août 2012
Modifié(e) : Matt Fig le 8 Août 2012
Use the logical negation symbol
~ismember(A,B)
or the functional form:
not(ismember(A,B))
  4 commentaires
Andrei Bobrov
Andrei Bobrov le 25 Déc 2012
Modifié(e) : Andrei Bobrov le 25 Déc 2012
flag = ~ismember(B,A);
index = find(flag);
or
[out,index] = setdiff(A,B);
Lalit Patil
Lalit Patil le 25 Déc 2012
Modifié(e) : Lalit Patil le 25 Déc 2012
It works by
flag = ~ismember(A,B);
index = find(flag);
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by