function WSMIN, array, val ;+ ;NAME: ; WSMIN ; ;PURPOSE: ; To find the minimum elements of an array or matrix. This ; function works the same way as Matlab's MIN: y=min(array, val) ; works. ; ;CATEGORY: ; Math. ; ;CALLING SEQUENCE: ; Result = WSMIN(array, val) ; ;INPUTS: ; Array: The data array. Array may be any type except string. ; val: a value that is compared with every element of Array ; ;OUTPUTS: ; Result = ; WSMIN returns the lowest value of an array element or "val", ; or if the array is a matrix, it returns the lowest value of ; each *column* in the matrix or "val". ;NOTES: IDL's indices are one less than Matlab's. ; ;EXAMPLE: ; IDL> array=[[1,2,3],[4,5,6],[7,8,9]] ; IDL> a = 1.4823 ; IDL> PRINT, array ; 1 2 3 ; 4 5 6 ; 7 8 9 ; IDL> y= WSMIN(array, a) ; IDL> PRINT, y ; ; 1.0000 1.4823 1.4823 ; 1.4823 1.4823 1.4823 ; 1.4823 1.4823 1.4823 ; ;MODIFICATION HISTORY: ; Amara Graps, September 1995. ; copyright (c) Amara Graps 1995, 1996. ;- newarray= array ind = WHERE(val LT array, count) CASE count OF 0: BEGIN ;no instances ;Array = Array END ELSE: BEGIN newarray(ind) = val END ENDCASE RETURN, newarray END