categorical.median
categorical: B = median (A)
categorical: B = median (A, dim)
categorical: B = median (A, vecdim)
categorical: B = median (A, 'all')
categorical: B = median (…, missingflag)
Median value of an ordinal categorical array.
B = median (A) returns the median of the elements in
ordinal categorical vector A. If A is a matrix,
median (A) returns a row vector with the median element
from each column. For multidimensional arrays, median (A)
operates along the first non-singleton dimension. B is also
ordinal with the same ordered categories as A. For even number of
elements along the operating dimension, the returned median value is
either the midway category between the two middle elements or the larger
of the two categories midway between the two middle elements.
B = median (A, dim) operates along the dimension
specified by dim.
B = median (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 = median (A, operates on
all dimensions and returns the median element in A.
[], 'all')
C = median (…, 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' ignores all undefined elements and returns
the median 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', which is the default, 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
median returns the middle category by rank — defined for ordinal arrays, where the categories have a genuine order.
C = categorical ({'S'; 'M'; 'L'; 'M'; 'L'}, {'S', 'M', 'L'}, 'Ordinal', true)
C =
5x1 categorical array
S
M
L
M
L
median (C)
ans = categorical M