categorical

Methods

Method Reference: categorical.max

categorical: C = max (A)
categorical: [C, index] = max (A)
categorical: C = max (A, [], dim)
categorical: C = max (A, [], vecdim)
categorical: C = max (A, [], 'all')
categorical: [C, index] = max (A, [], 'linear')
categorical: [C, index] = max (A, [], …, 'linear')
categorical: C = max (A, B)
categorical: […] = max (…, missingflag)

Largest elements in ordinal categorical arrays.

C = max (A) returns the largest element in ordinal categorical vector A. If A is a matrix, max (A) returns a row vector with the largest element from each column. For multidimensional arrays, max (A) operates along the first non-singleton dimension.

[C, index] = max (A) also returns the indices of the maximum values in index, which has the same size as C. When the operating dimension contains more than one maximal elements, the index of the first one is returned.

C = max (A, [], dim) operates along the dimension specified by dim.

C = max (A, [], vecdim) operates on all the elements contained in the dimensions specified by vecdim, which must be a numeric vector of non-repeating positive integers. Any values in vecdim indexing dimensions larger that the actual array A are ignored.

C = max (A, [], 'all') operates on all dimensions and returns the largest element in A.

[C, index] = max (A, [], …) also returns the first index of the maximum values in index. The second output is only valid when max operates on a single input array. Setting the 'linear' flag returns the linear index to the corresponding maximum values in A.

C = max (A, B) returns an ordinal categorical array C with the largest elements from A and B, which both must be ordinal categorical arrays of compatible sizes with the same set and ordering of categories. Compatible size means that A and B can be the same size, one can be scalar, or for every dimension, their dimension sizes must be equal or one of them must be 1.

[…] = max (…, missingflag) specifies how to handle undefined elements in any of the previous syntaxes. missingflag must be a character vector or a string scalar with one of the following values:

  • 'omitundefined', which is the default, ignores all undefined elements and returns the maximum of the remaining elements. If all elements along the operating dimension are undefined, then it returns an undefined element. 'omitnan' may also be used as equivalent to 'omitundefined'.
  • 'includeundefined' returns an undefined element if there any undefined elements along the operating dimension. 'includenan' may also be used as equivalent to 'includeundefined'.

Source Code: categorical

Example: 1

max returns the highest-ranked category present in an ordinal array, by category order rather than by label.

 C = categorical ({'M'; 'L'; 'S'; 'M'}, {'S', 'M', 'L'}, 'Ordinal', true)
C =
  4x1 categorical array

    M    
    L    
    S    
    M
 max (C)
ans =
  categorical

   L