min (replaces TMin)


The min function returns the minimum value of a 1-dimensional array, CImage, or list of numbers. The list of numbers must contain a mixture of numbers and strings that can be converted to numbers. This function is similar to the CStat:Min method but does not require calling new_stats() beforehand to create a CStats object. The related minxy function returns the minimum value and coordinates of the minimum value. The minn function returns the minimum value in a general n-dimensional table.

Syntax

nMin = min( Data )

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    nMin is the returned minimum value found in Data.

Remarks

All table types except for the CImage class real numbers with pixel type "double". 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 minimum value of a table containing 1 million random numbers.

t = random( 1000000 )

-- create a table of numbers

v = minxy( t )

-- find the minimum

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

-- list the minimum value

  

The next script returns the minimum 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 = min( V:GetImage() )

-- find the minimum value in the CImage

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

-- list the minimum value

  

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

v = min( 5, 6, "-2", 5.4 }

-- find the minimum value

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

-- result: Min = -2

Related Topics

Table and Array Functions

minxy

minn

max


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