MAX MAX Maximum Function Usage Computes the maximum 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 max function has a number of syntaxes. The first one computes the maximum of an array along a given dimension. The first general syntax for its use is either [y,n] = max(x,[],d) where x is a multidimensional array of numerical type, in which case the output y is the maximum of x along dimension d. The second argument n is the index that results in the maximum. In the event that multiple maxima are present with the same value, the index of the first maximum is used. The second general syntax for the use of the max function is [y,n] = max(x) In this case, the maximum is taken along the first non-singleton dimension of x. For complex data types, the maximum is based on the magnitude of the numbers. NaNs are ignored in the calculations. The third general syntax for the use of the max function is as a comparison function for pairs of arrays. Here, the general syntax is y = max(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.