categorical

Methods

Method Reference: categorical.min

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

Smallest elements in ordinal categorical arrays.

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

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

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

C = min (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 = min (A, [], 'all') operates on all dimensions and returns the smallest element in A.

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

C = min (A, B) returns an ordinal categorical array C with the smallest 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.

[…] = min (…, 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 minimum of the remaining elements. If all elements along the operating dimension are undefined, then it returns an undefined element. 'omitnan' can also be used as equivalent to 'omitundefined'.
  • 'includeundefined' returns an undefined element if there are any undefined elements along the operating dimension. 'includenan' can also be used as equivalent to 'includeundefined'.

Source Code: categorical

Example: 1

min returns the lowest-ranked category present in an ordinal array — ranking follows the category order, not the alphabetical label.

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

    M    
    L    
    S    
    M
 min (C)
ans =
  categorical

   S

A second output gives the index of that element (as for numeric min).

 [lo, idx] = min (C);
 idx
idx = 3