Home »
Public Forums »
archive »
nearest number
nearest number [message #49617] |
Sun, 06 August 2006 09:10 |
bressert@gmail.com
Messages: 8 Registered: February 2006
|
Junior Member |
|
|
Hello,
Im writing a bit of IDL code where a large array of floating numbers is
compared to one floating number. The aim of comparing the array to the
floating number to find which the values "closest" match. I had the
idea that I could write an algorithm that starts with the following
===========
index = where(array eq floating_value, count)
if (size(index, /n_elements) eq 1) AND (index eq -1) then begin ...
===========
This bit would find the index numbers of the array that would be
exactly the same to the floating number. If there is no number the
where function returns a -1. From this point, I could try and round off
the floating number and numbers in the array with smaller decimal
places until there is a match. Would this be the best approach? Or is
there already a built code in IDL or from someone else that does this?
Any help is appreciated. Thanks!
Eli
|
|
|
Current Time: Wed Oct 08 13:49:17 PDT 2025
Total time taken to generate the page: 0.00412 seconds