function WMMIN, array, ind ;+ ;NAME: ; WMMIN ; ;PURPOSE: ; To find the minimum elements of an array or matrix. This ; function works the same way as Matlab's MIN: [y,ind]=min(array) ; works. ; ;CATEGORY: ; Math. ;CALLING SEQUENCE: ; Result = WMMIN(array, ind) ; ;INPUTS: ; Array: The data array. Array may be any type except string. ; ;OUTPUTS: ; Result = ; WMMIN returns the lowest value of an array, or if the array ; is a matrix, it returns the lowest value of each *column* in ; the matrix. ; ind = the index of the lowest value(s). ; ;NOTES: IDL's indices are one less than Matlab's. ; ;EXAMPLE: ; >array=[[1,3,2],[6,3,4],[9,1,0]] ; >print, array ; 1 3 2 ; 6 3 4 ; 9 1 0 ; y= WMMIN(array, ind) ; >print, y ; 1 1 0 ; >print, ind ; 0 2 2 ; ;MODIFICATION HISTORY: ; Amara Graps, BAER, December 1994. ; copyright (c) Amara Graps 1995, 1996. ;- t = SIZE(array) IF t(0) eq 1 THEN BEGIN ;1D array minval = MIN(array) ind = !c ENDIF ELSE BEGIN ;Matrix numcol = t(1) ;number of columns numrow=t(2) ;number of rows minval = FLTARR(numcol) ind = FLTARR(numcol) ;Step through the cols, and find the mins of the columns ;(the way Matlab does it) FOR i = 0, numcol-1 DO BEGIN tt = array(i,*) minval(i) = MIN(tt) ind(i) = !c END ;i ENDELSE !c = 0 RETURN, minval END