MATLAB Function Reference    

Detect members of a specific set



tf = ismember(A,S) returns a vector the same length as A containing logical true (1) where the elements of A are in the set S, and logical false (0) elsewhere. In set theoretic terms, k is 1 where A S. A and S can be cell arrays of strings.

tf = ismember(A,S,'rows') when A and S are matrices with the same number of columns returns a vector containing 1 where the rows of A are also rows of S and 0 otherwise.

[tf, loc] = ismember(A,S,...) returns index vector loc containing the highest index in S for each element in A that is a member of S. For those elements of A that do not occur in S, ismember returns 0.


See Also

issorted, intersect, setdiff, setxor, union, unique, is*

  islogical ismethod (COM)