MATLAB Function Reference | ![]() ![]() |
Syntax
k = ismember(a,S) k = ismember(A,S,'rows')
Description
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
. a and S can be cell arrays of strings.
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.
Examples
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
See Also
intersect
, setdiff
, setxor
, union
, unique
, is*
![]() | iskeyword | isocaps | ![]() |