[ncl-talk] sub: Closest value function
dale zuri
dalezuri at gmail.com
Thu Mar 21 04:09:24 MDT 2019
Hi Ncl user,
I would like to implement the closest value function without using ind
function. I would appreciate any suggestion.
value2check = 18.382
array2check = (/18.0001 ,18.5888, 18.01, 18.5/)
index = closest_val(value2check,array2check)
print(index)
xAbsDif = abs(value2check-array2check)
xMinVal = min(xAbsDif)
iClose = (ind(xAbsDif.eq.xMinVal))
print(iClose)
:::::without using ind;;;;;
do i=0,3
if any(xAbsDif(i)) .eq. any(xMinVal) then
print(i) ;; it's not giving right answer
end if
end do
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190321/afeef81e/attachment.html>
More information about the ncl-talk
mailing list