categorical.setdiff
categorical: C = setdiff (A, B)
categorical: C = setdiff (A, B, 'rows')
categorical: [C, ixA] = setdiff (…)
categorical: … = setdiff (…, order)
Set difference of two categorical arrays.
C = setdiff (A, B) returns the unique common
values of the categorical arrays A and B. Either A or
B input arguments may be a character vector, a string array, or a
cell array of character vectors, which is promoted to a categorical array
prior to set difference. If both A and B are row vectors,
then C is also a row vector, otherwise intersect returns a
column vector.
If categorical arrays A and B are ordinal, they must have the same set and ordering of categories, which is transfered to C. If neither are ordinal, the category names of each pair of elements are compared (they do not need to have the same set of categories) in which case the categories in C are the sorted union of the categories in A and B.
C = setdiff (A, B, returns the
unique common rows of the categorical matrices A and B, which
must have the same number of columns. By default, the rows in
categorical matrix C are in sorted order.
'rows'
[C, ixA] = setdiff (…) also returns the index
vector ixA such that C = A(ixA), unless
the 'rows' optional argument is given, in which case
C = A(ixA,:).
… = setdiff (…, order) also specifies the
order of the returned unique values. order may be either
'sorted', which is the default behavior, or 'stable',
in which case the unique values are returned in order of appearance.
Source Code: categorical
setdiff returns the values present in the first array but not the second.
A = categorical ({'S'; 'M'; 'L'})
A =
3x1 categorical array
S
M
L
B = categorical ({'M'; 'L'; 'XL'})
B =
3x1 categorical array
M
L
XL
setdiff (A, B)
ans = categorical S