ismember
Find set members of data
Syntax
Description
returns an array containing logical Lia
= ismember(A
,B
)1
(true
) where the data in A
is found in
B
. Elsewhere, the array contains logical
0
(false
).
If
A
andB
are tables or timetables, thenismember
returns a logical value for each row. For timetables,ismember
takes row times into account to determine equality. The output,Lia
, is a column vector.
treats each row of Lia
= ismember(A
,B
,"rows")A
and each row of B
as
single entities and returns a column vector containing logical
1
(true
) where the rows of
A
are also rows of B
. Elsewhere, the
array contains logical 0
(false
).
The "rows"
option does not support cell arrays, unless one
of the inputs is either a categorical array or a datetime array.
[
also returns an array, Lia
,Locb
]
= ismember(___)Locb
, using any of the previous syntaxes.
Generally,
Locb
contains the lowest index inB
for each value inA
that is a member ofB
. Values of0
indicate whereA
is not a member ofB
.If the
"rows"
option is specified, thenLocb
contains the lowest index inB
for each row inA
that is also a row inB
. Values of0
indicate whereA
is not a row ofB
.If
A
andB
are tables or timetables, thenLocb
contains the lowest index inB
for each row inA
that is also a row inB
. Values of0
indicate whereA
is not a row ofB
.
Examples
Input Arguments
Output Arguments
Tips
Use
ismembertol
to perform comparisons between floating-point numbers using a tolerance.To find the rows from table or timetable
A
that are found inB
with respect to a subset of variables, you can use column subscripting. For example, you can useismember(A(:,
, wherevars
),B(:,vars
))vars
is a positive integer, a vector of positive integers, a variable name, a string array or cell array of variable names, or a logical vector. Alternatively, you can usevartype
to create a subscript that selects variables of a specified type.
Extended Capabilities
Version History
Introduced before R2006a