comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: nearest number
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: nearest number [message #49610 is a reply to message #49608] Mon, 07 August 2006 06:52 Go to previous messageGo to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
bressert@gmail.com wrote:
> 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!

Hi,

Check out the following thread - JD Smith discusses a couple of
approaches to solve this kind of problem.

http://tinyurl.com/e6ke7

Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Writing a structure containing empty strings
Next Topic: Re: file_lines and expand path

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:13:51 PDT 2025

Total time taken to generate the page: 2.00274 seconds