max
max
(maxv, ind)=max(a)
(maxv)=max(a, b, c, d, ....)
Inputs
a Any numeric array.
{b, c, d,...} Numeric arrays of the same size as a or scalars.
Outputs
maxv The maximum value.
ind The indices associated with the maximum value in the input array.


Description
If there are multiple inputs to the function, all the inputs which are not scalars must be of the the same size. In this case, the function returns an array of the same size as the non-scalar inputs, and each element of the output is the maximum of the corresponding elements of the inputs. If any of the inputs is a scalar, for the purposes of comparison, it is replaced by an array of the same size as the other inputs with all its elements set equal to the scalar.

If there is only one input, and the input is a vector, maxv is its largest element, with ind being the index of this element.

If there is only one input, and the input is a matrix, maxv is the row vector of the maximal element of each of the columns, and the corresponding element in ind is the index of the maximal element in the column. In the case, maxv can also be obtained from the expression shuffle(a, ind) .

If there is only one input, and the input is a multi-dimensional array, the outputs maxv and ind are of the same size as the input except that along the first dimension the size is one, and maxv[1,i,j,k,...] , with scalar i, j, k, ... ranging from one to the length of the array in the corresponding dimension, is the maximal element of the vector a[:,i,j,k,...] , and ind[1,i,j,k,...] is the index of the maximal element in this vector. In this case, maxv can also be obtained from the expression shuffle(a, ind) .
Example
>>max(2,3,4,2,4)
       4
>>a=rand(4,5,6)
>>(mx,ind)=max(a)
>>norm(mx-shuffle(a,ind))
       0