MATLAB Functions | Help Desk |
ismember
Detect members of a set
k = ismember(a,S) k = ismember(A,S,'rows')
k = ismember(a,S)
returns an 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
.
k = 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.
set = [0 2 4 6 8 10 12 14 16 18 20]; a = reshape(1:5,[5 1]) a = 1 2 3 4 5 ismember(a,set) ans = 0 1 0 1 0
intersect
Set intersection of two vectors
setdiff
Return the set difference of two vectors
setxor
Set exclusive-or of two vectors
union
Set union of two vectors
unique
Unique elements of a vector