bounds

Smallest and largest elements of an array, returned together.

Category: Data Import and Analysis > Descriptive Statistics

Syntax

[smin, smax] = bounds(A)

Minimum and maximum along the first non-singleton dimension.

[smin, smax] = bounds(A, dim)

Along dimension dim.

[smin, smax] = bounds(A, 'all')

Over every element of A.

Description

bounds is the same as calling min and max separately, in one pass. For a matrix it returns a row vector of column minima and another of column maxima. NaN values are ignored unless every element is NaN.

Input arguments

A
Numeric array.
dim
Dimension to operate along.

Output arguments

smin
Smallest values.
smax
Largest values.

Example

Range of a matrix

A = [1 5; 3 2; 4 9];
[lo, hi] = bounds(A)
[lo, hi] = bounds(A, 2)
Output
lo = 1×2

     1     2
hi = 1×2

     4     9
lo = 3×1

     1
     2
     4
hi = 3×1

     5
     3
     9

See also

min max maxk mink