function opposite of ismember?

36 ビュー (過去 30 日間)
S
S 2012 年 8 月 8 日
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

採用された回答

Matt Fig
Matt Fig 2012 年 8 月 8 日
編集済み: Matt Fig 2012 年 8 月 8 日
Use the logical negation symbol
~ismember(A,B)
or the functional form:
not(ismember(A,B))
  4 件のコメント
Andrei Bobrov
Andrei Bobrov 2012 年 12 月 25 日
編集済み: Andrei Bobrov 2012 年 12 月 25 日
flag = ~ismember(B,A);
index = find(flag);
or
[out,index] = setdiff(A,B);
Lalit Patil
Lalit Patil 2012 年 12 月 25 日
編集済み: Lalit Patil 2012 年 12 月 25 日
It works by
flag = ~ismember(A,B);
index = find(flag);
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by