Quantcast

Documentation Center

  • Trial Software
  • Product Updates

ismember

Class: categorical

True for elements of categorical array in set

The nominal and ordinal array data types might be removed in a future release. To represent ordered and unordered discrete, nonnumeric data, use the MATLAB® categorical data type instead.

Syntax

TF = ismember(A,B)
[TF,LOCB] = ismember(A,B)
[...] = ismember(A,B,'rows')
[...] = intersect(...,'legacy')

Description

TF = ismember(A,B) for categorical arrays A and B, returns a logical array the same size as A, containing true (1) where the elements of A are in B, and false (0) otherwise. B can also be a cell array of strings or two-dimensional character array containing level labels.

[TF,LOCB] = ismember(A,B) also returns an index array LOCB containing the highest absolute index in B for each element in A which is a member of B, and 0 if there is no such index.

[...] = ismember(A,B,'rows'), for categorical matrices A and B with the same number of columns, returns a logical vector containing true (1) where the rows of A are also rows of B, and false (0) otherwise. The optional output LOCB is an index vector containing the highest absolute index in B for each row in A which is a member of B and 0 if there is no such index.

[...] = intersect(...,'legacy') preserves the pre-2012a behavior of ismember. You can specify the flag as the final argument with any previous syntax that accepts A, B, or 'rows'.

See Also

| | | | |

Was this topic helpful?