Documentation |
Array elements that are members of set array
Lia = ismember(A,B) returns an array containing 1 (true) where the data in A is found in B. Elsewhere, it returns 0 (false).
If A and B are numeric arrays, logical arrays, character arrays, categorical arrays, datetime arrays, duration arrays, or cell arrays of strings, then ismember returns a logical value for each element of A. The output, Lia, is an array of the same size as A.
If A and B are tables, then ismember returns a logical value for each row of A. The output, Lia, is a column vector with the same number of rows as A.
Lia = ismember(A,B,'rows') treats each row of A and each row of B as single entities and returns a column vector containing 1 (true) where the rows of A are also rows of B. Elsewhere, it returns 0 (false).
A and B must have the same number of columns when you use the 'rows' option. Furthermore, the 'rows' option does not support cell arrays, unless one of the inputs is either a categorical array or a datetime array.
[Lia,Locb] = ismember(A,B) also returns an array, Locb.
If A and B are numeric arrays, logical arrays, character arrays, categorical arrays, datetime arrays, duration arrays, or cell arrays of strings, then Locb contains the lowest index in B for each value in A that is a member of B. The output array, Locb, contains 0 wherever A is not a member of B.
If A and B are tables, then Locb contains the lowest index in B for each row in A that is also a row in B. The output vector, Locb, contains 0 whenever A is not a row of B.