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

Home » Public Forums » archive » Looking for a search routine
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: Looking for a search routine [message #5398 is a reply to message #5274] Mon, 27 November 1995 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
jvkepner@airy.Princeton.EDU (Jeremy Kepner) wrote:
> I have two 1D floating point vectors X and Y.
> Y contains values sorted in increasing order. I am
> looking for a function that for each element in the
> X array, X(i), will return the index of the element in the
> Y array that is nearest to X(i). Ideally it would
> be a function that would look something like
>
> y_ids = SEARCH(X,Y)

For each element of X, to find the index of the closest value in Y, do

D = MIN(ABS(Y-X(I)),LOC)

where I is the loop index for X, and LOC is the index of the closest value in
Y.
You might be able to do this without a loop, but I'm not sure exactly how.

Cheers,
Liam.
[Message index]
 
Read Message
Read Message
Previous Topic: Please explain...
Next Topic: Importing IDL Postscript output into Windows apps

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

Current Time: Sun Apr 26 13:49:41 PDT 2026

Total time taken to generate the page: 0.16124 seconds