# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# bounds

Smallest and largest elements

## Syntax

``````[S,L] = bounds(A)``````
``````[S,L] = bounds(A,dim)``````
``````[S,L] = bounds(___,nanflag)``````

## Description

example

``````[S,L] = bounds(A)``` returns the smallest element `S` and largest element `L` of an array. `S` is equivalent to `min(A)` and `L` is equivalent to `max(A)`.```

example

``````[S,L] = bounds(A,dim)``` operates along the dimension `dim` of `A`. For example, if `A` is a matrix, then `bounds(A,2)` returns column vectors `S` and `L` containing the smallest and largest elements of each row.```

example

``````[S,L] = bounds(___,nanflag)``` specifies whether to include or omit `NaN` values when determining the smallest and largest elements. `bounds(A,'omitnan')` ignores `NaN` values. If any element of `A` is `NaN`, then `bounds(A,'includenan')` returns `NaN` for both `S` and `L`. The default behavior is `'omitnan'`.```

## Examples

collapse all

Simultaneously compute the smallest and largest values of a vector.

```A = [2 4 -1 10 6 3 0 -16]; [S,L] = bounds(A)```
```S = -16 ```
```L = 10 ```

Compute the smallest and largest elements of each row of a matrix.

`A = magic(4)`
```A = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 ```
`[S,L] = bounds(A,2)`
```S = 2 5 6 1 ```
```L = 16 11 12 15 ```

Include and ignore NaN elements of a vector when computing its smallest and largest values.

Ignore `NaN` values when computing the largest and smallest values of a vector, which is the default.

```A = [2 NaN 6 -5 0 NaN 10]; [S,L] = bounds(A)```
```S = -5 ```
```L = 10 ```

Use the `'includenan'` option to include `NaN` values, which causes `bounds` to return `NaN` for both the smallest and largest values of `A`.

`[S,L] = bounds(A,'includenan')`
```S = NaN ```
```L = NaN ```

## Input Arguments

collapse all

Input array, specified as a vector, matrix, or multidimensional array.

Example:

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `categorical` | `datetime` | `duration`
Complex Number Support: Yes

Dimension to operate along, specified as a positive integer scalar. If no value is specified, then the default is the first array dimension whose size does not equal 1.

Consider a matrix `A`.

• `bounds(A,1)` computes the smallest and largest values of each column.

• `bounds(A,2)` computes the smallest and largest values of each row.

Data Types: `double` | `single` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

`NaN` condition, specified as one of these values:

• `'omitnan'` — Ignore all `NaN` values in the input. If the input contains only `NaN` values, then `bounds` returns `NaN` for both `S` and `L`.

• `'includenan'` — Include `NaN` values. If any element of the input is `NaN`, then `bounds` returns `NaN` for both `S` and `L`.

## Output Arguments

collapse all

Smallest element, specified as a vector, matrix, or multidimensional array.

Largest element, specified as a vector, matrix, or multidimensional array.