MIN Function
Returns the value of the smallest element in array.
enabled.
Usage
Input Parameters
array—The array to be searched.
min_subscript—(optional) The subscript of the smallest element in array:
-
If supplied, min_subscript is converted to a long integer containing the one-dimensional subscript of the smallest element.
-
If min_subscript is not supplied, the system variable !C is set to the one-dimensional subscript of the smallest element.
Returned Value
result—The value of the smallest element in array. The result is given in the same data type as array. If the Dimension keyword is used, then the values of result, min_subscript, and Max will all have the structure of the input array, but with dimension n collapsed.
Note: If array is complex then the returned value is the element of array with the minimum real part. |
Keywords
Max—Used to specify a variable to hold value of the largest array element.
Dimension—An integer (n ≥ 0) designating the dimension over which the minimum is taken.
Note: If you need to find both the minimum and maximum array values, use the Max keyword to avoid having to scan the array twice using separate calls to MAX and MIN. |
Example 1
x = [22, 40, 9, 12] PRINT, MIN(x) ; PV-WAVE prints: 9
Example 2
x = [3, 4, 5, 6, 7, 8, 9] minval = MIN(x, minindex, Max=maxval) PRINT, minval ; PV-WAVE prints: 3 PRINT, minindex ; PV-WAVE prints: 0 PRINT, maxval ; PV-WAVE prints: 9
Example 3
a = [[1,1,3,2], [3,4,1,3], [3,0,1,0], [0,1,2,0]] PM, a ; PV-WAVE prints: ; 1 3 3 0 ; 1 4 0 1 ; 3 1 1 2 ; 2 3 0 0 PM, MIN(a, Dimension=0) ; PV-WAVE prints: ; 1 1 0 0 PM, MIN(a, Dimension=1) ; PV-WAVE prints: ; 0 ; 0 ; 1 ; 0 a = INDGEN( 1, 2, 3, 4, 5 ) INFO, MIN(a, Dimension=2) ; PV-WAVE prints: <Expression> INT = Array(1, 2, 1, 4, 5)