function opposite of ismember?
53 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
Matt Fig
il 8 Ago 2012
Modificato: Matt Fig
il 8 Ago 2012
Use the logical negation symbol
~ismember(A,B)
or the functional form:
not(ismember(A,B))
4 Commenti
Andrei Bobrov
il 25 Dic 2012
Modificato: Andrei Bobrov
il 25 Dic 2012
flag = ~ismember(B,A);
index = find(flag);
or
[out,index] = setdiff(A,B);
Lalit Patil
il 25 Dic 2012
Modificato: Lalit Patil
il 25 Dic 2012
It works by
flag = ~ismember(A,B);
index = find(flag);
Thank you.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!