list maxxy

max (replaces TMax)


The max function returns the maximum value of a 1-dimensional array, CImage, or list of numbers. This function is similar to the CStat:Max method but does not require calling new_stats() beforehand to create a CStats object. The related maxxy function returns the maximum value and its coordinates in the data The related maxxy function returns the maximum value and coordinates of the maximum value.

Whereas this function operates on a pure (indexed) array, the slightly slower maxn function returns the maximum value in a general n-dimensional table.

Syntax

nMax = max( Data )

nMax = max( n1, n2, n3, ... )

bullet.gif    Data is a 1-dimensional array, list of numbers, or a CImage object.

bullet.gif    n1, n2, n3, ... are numbers or string values that can be converted to numbers.

bullet.gif    nMax is the maximum value found in Data.

Remarks

The CImage class supports values ranging from byte to double plus other pixel types.

For a CMatrix, the returned nX and nY can be difficult to untangle because the CMatrix does not require a fixed number of columns in each row.

Examples

The following script returns the maximum value of a table containing 1 million random numbers.

t = random( 1000000 )

-- create a table of numbers

v = max( t )

-- find the maximum value

Printf("Max = %lg\n", v )

-- list the maximum value

  

The next script returns the maximum value for pixels in a CImage.

V = AttachView( "CImageView" )

-- attach the topmost image window

Assert( V and V:Count() > 0 )

-- make sure an image window is on top

v = max( V:GetImage() )

-- use the current image in the CImageView

Printf("Max = %lg\n", v )

-- list the maximum value

  

The next example computes the maximum value of a list of numbers:

v = max( 5, 6, -2, "8.4" }

-- find the maximum value

Printf("Max = %lg\n", v )

-- result: Max = 8.4

Related Topics

Table and Array Functions

maxxy

maxn

min

CImageView Class


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.