categorical

Methods

Method Reference: categorical.vertcat

categorical: C = vertcat (A, B, …)

Vertical concatenation of categorical arrays.

C = vertcat (A, B, … is the equivalent of the syntax B = [A; B; …] and vertically concatenates the categorical arrays A, B, …. All input arrays must have the same size except along the first dimension. Any of the input arrays may also be string arrays or cell arrays of character vectors of compatible size.

If any input array is an ordinal categorical array, then all inputs must be ordinal categorical arrays with the same set and ordering of categories. In this case, C is also an ordinal categorical array with the same set and ordering of categories. If none of the input arrays are ordinal, then they do not need to have the same set of categories. In this case, categorical array C contains the union of the categories from all input arrays. Protected categorical arrays can only be concatenated with other arrays that have the same set of categories but not necessarily in the same order.

Source Code: categorical

Example: 1

Concatenating categorical arrays unions their category lists, so the result can hold categories that neither operand had alone. [A; B] stacks them.

 A = categorical ({'S'; 'M'})
A =
  2x1 categorical array

    S    
    M
 B = categorical ({'L'; 'XL'})
B =
  2x1 categorical array

    L     
    XL
 C = [A; B];
 C
C =
  4x1 categorical array

    S     
    M     
    L     
    XL
 categories (C)
ans =
  4x1 cell array

    {'M' }    
    {'S' }    
    {'L' }    
    {'XL'}