ismember
Find set members of data
Syntax
Description
Lia = ismember(A,B)1
                        (true) where the data in A is found in
                        B. Elsewhere, the array contains logical
                        0 (false).
- If - Aand- Bare tables or timetables, then- ismemberreturns a logical value for each row. For timetables,- ismembertakes row times into account to determine equality. The output,- Lia, is a column vector.
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 in- Bfor each value in- Athat is a member of- B. Values of- 0indicate where- Ais not a member of- B.
- If the - "rows"option is specified, then- Locbcontains the lowest index in- Bfor each row in- Athat is also a row in- B. Values of- 0indicate where- Ais not a row of- B.
- If - Aand- Bare tables or timetables, then- Locbcontains the lowest index in- Bfor each row in- Athat is also a row in- B. Values of- 0indicate where- Ais not a row of- B.
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 in- Bwith respect to a subset of variables, you can use column subscripting. For example, you can use- ismember(A(:,, where- vars),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 use- vartypeto create a subscript that selects variables of a specified type.
Extended Capabilities
Version History
Introduced before R2006a