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
AandBare tables or timetables, thenismemberreturns a logical value for each row. For timetables,ismembertakes 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,
Locbcontains the lowest index inBfor each value inAthat is a member ofB. Values of0indicate whereAis not a member ofB.If the
"rows"option is specified, thenLocbcontains the lowest index inBfor each row inAthat is also a row inB. Values of0indicate whereAis not a row ofB.If
AandBare tables or timetables, thenLocbcontains the lowest index inBfor each row inAthat is also a row inB. Values of0indicate whereAis not a row ofB.
Examples
Input Arguments
Output Arguments
Tips
Use
ismembertolto perform comparisons between floating-point numbers using a tolerance.To find the rows from table or timetable
Athat are found inBwith respect to a subset of variables, you can use column subscripting. For example, you can useismember(A(:,, wherevars),B(:,vars))varsis 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 usevartypeto create a subscript that selects variables of a specified type.
Extended Capabilities
Version History
Introduced before R2006a