function opposite of ismember?

조회 수: 48 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by