
 Usage

Computes the minimum of an array along a given dimension, or
alternately, computes two arrays (entry-wise) and keeps the
smaller value for each array. As a result, the min function
has a number of syntaxes. The first one computes the minimum
of an array along a given dimension. The first general
syntax for its use is either

     [y,n] = min(x,[],d)

where x is a multidimensional array of numerical type, in
which case the output y is the minimum of x along dimension
d. The second argument n is the index that results in the
minimum. In the event that multiple minima are present with
the same value, the index of the first minimum is used. The
second general syntax for the use of the min function is

     [y,n] = min(x)

In this case, the minimum is taken along the first non-
singleton dimension of x. For complex data types, the
minimum is based on the magnitude of the numbers. NaNs are
ignored in the calculations. The third general syntax for
the use of the min function is as a comparison function for
pairs of arrays. Here, the general syntax is

     y = min(x,z)

where x and z are either both numerical arrays of the same
dimensions, or one of the two is a scalar. In the first
case, the output is the same size as both arrays, and is
defined elementwise by the smaller of the two arrays. In the
second case, the output is defined elementwise by the
smaller of the array entries and the scalar.


 Internals

In the general version of the min function which is applied
to a single array (using the min(x,[],d) or min(x)
syntaxes), The output is computed via
 \[ y(m_1,\ldots,m_{d-1},1,m_{d+1},\ldots,m_{p}) = \min_{k}
x(m_1,\ldots,m_{d-1},k,m_{d+1},\ldots,m_{p}), \]
and the output array n of indices is calculated via
 \[ n(m_1,\ldots,m_{d-1},1,m_{d+1},\ldots,m_{p}) = \arg
\min_{k} x(m_1,\ldots,m_{d-1},k,m_{d+1},\ldots,m_{p}) \]
In the two-array version (min(x,z)), the single output is
computed as
 \[ y(m_1,\ldots,m_{d-1},1,m_{d+1},\ldots,m_{p}) = \begin
{cases} x(m_1,\ldots,m_{d-1},k,m_{d+1},\ldots,m_{p}) &amp; x
(\cdots) \leq z(\cdots) \\ z(m_1,\ldots,m_{d-1},k,m_
{d+1},\ldots,m_{p}) &amp; z(\cdots) < x(\cdots). \end{cases}
\]


 Example

The following piece of code demonstrates various uses of the
minimum function. We start with the one-array version.

  --> A = [5,1,3;3,2,1;0,3,1]

  A =
   5 1 3
   3 2 1
   0 3 1

We first take the minimum along the columns, resulting in a
row vector.

  --> min(A)

  ans =
   0 1 1

Next, we take the minimum along the rows, resulting in a
column vector.

  --> min(A,[],2)

  ans =
   1
   1
   0

When the dimension argument is not supplied, min acts along
the first non-singular dimension. For a row vector, this is
the column direction:

  --> min([5,3,2,9])

  ans =
   2

For the two-argument version, we can compute the smaller of
two arrays, as in this example:

  --> a = int8(100*randn(4))

  a =
    -66  -74  -74   32
   -128  -14 -110 -128
    127  -96  -49   72
    127   50   83  120

  --> b = int8(100*randn(4))

  b =
    -94  108  -99  -35
    127   50 -100  113
    -98  -39 -127 -107
    -12  127  103  -44

  --> min(a,b)

  ans =
    -94  -74  -99  -35
   -128  -14 -110 -128
    -98  -96 -127 -107
    -12   50   83  -44

Or alternately, we can compare an array with a scalar

  --> a = randn(2)

  a =
      0.7713    0.6716
     -1.0581   -1.3734

  --> min(a,0)

  ans =
           0         0
     -1.0581   -1.3734


* FreeMat_Documentation
* Elementary_Functions
* Generated on Thu Jul 25 2013 17:17:14 for FreeMat by
  doxygen_ 1.8.1.1

