nanmax
'all'
)Find the maximum while ignoring NaN values.
v = nanmax (x)
returns the maximum of x, after
removing NaN
values. If x is a vector, a scalar maximum value
is returned. If x is a matrix, a row vector of column maxima is
returned. If x is a multidimentional array, the nanmax
operates
along the fisrt nonsigleton dimension. If all values in a column are
NaN
, the maximum is returned as NaN
rather than []
.
v = nanmax (x, [], dim)
operates along the dimension
dim of x.
[v, idx] = nanmax (…)
also returns the row indices
of the maximum values for each column in the vector idx. When x
is a vector, then idx is a scalar value as v.
v = nanmax (x, [],
returns the maximum of
all elements of x, after removing 'all'
)NaN
values. It is the
equivalent of nanmax (x(:))
. The optional flag 'all'
cannot be used together with dim or vecdim input arguments.
v = nanmax (x, [], vecdim)
returns the maximum over
the dimensions specified in the vector vecdim. Each element of
vecdim represents a dimension of the input array x and the output
v has length 1 in the specified operating dimensions. The lengths of
the other dimensions are the same for x and y. For example, if
x is a 2-by-3-by-4 array, then nanmax (x, [1 2])
returns a
1-by-1-by-4 array. Each element of the output array is the maximum of the
elements on the corresponding page of x. If vecdim indexes all
dimensions of x, then it is equivalent to
nanmax (x,
. Any dimension in vecdim
greater than 'all'
)ndims (x)
is ignored.
Source Code: nanmax
## Find the column maximum values and their indices ## for matrix data with missing values. x = magic (3); x([1, 6:9]) = NaN [y, ind] = nanmax (x) x = NaN 1 NaN 3 5 NaN 4 NaN NaN y = 4 5 NaN ind = 3 2 1 |
## Find the maximum of all the values in an array, ignoring missing values. ## Create a 2-by-5-by-3 array x with some missing values. x = reshape (1:30, [2, 5, 3]); x([10:12, 25]) = NaN ## Find the maximum of the elements of x. y = nanmax (x, [], 'all') x = ans(:,:,1) = 1 3 5 7 9 2 4 6 8 NaN ans(:,:,2) = NaN 13 15 17 19 NaN 14 16 18 20 ans(:,:,3) = 21 23 NaN 27 29 22 24 26 28 30 y = 30 |