MAL.Min

Previous  Next

 

value = MAL.Min( BYREF data    AS ARRAY,

                [BYVAL vixa    AS INTEGER=0],

                [BYVAL nFrames AS INTEGER=ML_ALL] ) AS REAL

 

index = MAL.Min( BYREF data    AS ARRAY,

                [BYVAL vixa    AS INTEGER=0],

                [BYVAL nFrames AS INTEGER=ML_ALL],

                [BYVAL bIndex  AS INTEGER=FALSE] ) AS INTEGER

 


 

Returns the minimum value of a 1 dimensional array.  If bIndex is set, then the index into the array is returned instead of the value.

 

You can specify array index using a VIX if the input is a multidimensional array.

 

Example:

 

OPTION EXPLICIT ON

OPTION BASE 1

 

' Include C3D Support

$INCLUDE "MyBASIC2_C3DFile"

$LIBRARY "MyBASIC2_C3DFileLib"

 

' Include the MaxMAL Library

$INCLUDE "MyBASIC2_MaxMAL"

$LIBRARY "MyBASIC2_MaxMALLib"

 

' Declare variables and arrays

DIM nPoints AS INTEGER

DIM nFrames AS INTEGER

DIM hFile   AS INTEGER

DIM i       AS INTEGER

DIM fid     AS HANDLE

 

CONST cFileName = "e:\walk8.c3d"

 

CLS

 

' Open the Test File

hFile = C3DFile.Open( cFileName );

 

IF NOT hFile > 0 THEN

  PRINT "Error Opening File ";cFileName,

  STOP

ENDIF

 

' Get the no of points and frames

nFrames = C3DFile.GetNoOfFrames( hFile )

nPoints = C3DFile.GetNoOfPoints( hFile )

 

' Dimension the arrays

DIM arrPoints(nFrames,nPoints,3) AS REAL

 

IF C3DFile.GetPoints( hFile, arrPoints ) <> nFrames THEN

  C3DFile.Close( hFile )

  PRINT "Error Reading ";nPoints;" from file ";cFileName,

  STOP

ENDIF

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''' Test MAL Statistical Functions ''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'

DIM rMax_X     AS REAL

DIM rMax_Y     AS REAL

DIM rMin_X     AS REAL

DIM rMin_Y     AS REAL

'

DIM iMax_X     AS INTEGER

DIM iMax_Y     AS INTEGER

DIM iMin_X     AS INTEGER

DIM iMin_Y     AS INTEGER

'

DIM rMean_X    AS REAL

DIM rMedian_X  AS REAL

DIM rSum_X     AS REAL

'

DIM rMean_Y    AS REAL

DIM rMedian_Y  AS REAL

DIM rSum_Y     AS REAL

'

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'

DIM strFormat  AS STRING

'

strFormat = "Point %1d: " +_

           "Min_X[%03d] =%8.3f, Min_Y[%03d] =%8.3f, " +_

           "Max_X[%03d] =%8.3f, Max_Y[%03d] =%8.3f, " +_

           "Mean_X =%8.3f, Mean_Y =%8.3f, " +_

           "Median_X =%8.3f, Median_Y =%8.3f, " +_

           "Sum_X =%10.2f, Sum_Y =%10.2f"

'

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'

FOR i = 1 TO nPoints

  rMax_X = MAL.Max( arrPoints, VIX( i, 1 ) )

  iMax_X = MAL.Max( arrPoints, VIX( i, 1 ), ML_ALL, TRUE )

 

  rMax_Y = MAL.Max( arrPoints, VIX( i, 2 ) )

  iMax_Y = MAL.Max( arrPoints, VIX( i, 2 ), ML_ALL, TRUE )

 

  rMin_X = MAL.Min( arrPoints, VIX( i, 1 ) )

  iMin_X = MAL.Min( arrPoints, VIX( i, 1 ), ML_ALL, TRUE )

 

  rMin_Y = MAL.Min( arrPoints, VIX( i, 2 ) )

  iMin_Y = MAL.Min( arrPoints, VIX( i, 2 ), ML_ALL, TRUE )

 

  rMean_X = MAL.Mean( arrPoints, VIX( i, 1 ) )

  rMean_Y = MAL.Mean( arrPoints, VIX( i, 2 ) )

 

  rMedian_X = MAL.Median( arrPoints, VIX( i, 1 ) )

  rMedian_Y = MAL.Median( arrPoints, VIX( i, 2 ) )

 

  rSum_X = MAL.Sum( arrPoints, VIX( i, 1 ) )

  rSum_Y = MAL.Sum( arrPoints, VIX( i, 2 ) )

 

  PRINT FORMAT( strFormat,_

                i,_

                iMin_X, rMin_X, iMin_Y, rMin_Y,_

                iMax_X, rMax_X, iMax_Y, rMax_Y,_

                rMean_X, rMean_Y,_

                rMedian_X, rMedian_Y,_

                rSum_X, rSum_Y ),

ENDFOR

'

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 

' We're done testing.  Close File

C3DFile.Close( hFile )

 

END