# findClosest

Return the closest value in a matrix.

## Syntax

    value = findClosest(A, a)
    [value, index] = findClosest(A, a)

## Description

`findClosest` returns the value and index of the item in A that is closest to the value a. For vectors, value and index correspond to the closest element in A. For matrices, value and index are row vectors corresponding to the closest element from each column. For N-D arrays, the function finds the closest value along the first non-singleton dimension. If there is more than one element with the closest value, the index of the first one is returned.

## Inputs

`A` | matrix to search
`a` | value to find

## Outputs

`value` | value in A that is closest to a
`index` | the index of a within A

## See Also

`find`, `min`