[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a vector of indices of the largest elements in a vector not exceeding the elements of some other vector

derek@milkyway.gsfc.nasa.gov (Derek Hullinger) writes:

> I have two vectors of different sizes (say, A and B):
> 	A contains floating point values that increase with index
> 	B contains floating point values
> I'd like to create a third vector, C (which would be the same size as
> B) such that:
> 	The nth element in C contains the index of the largest element in A
> that does not exceed the nth element in B.

What you are asking for is *exactly* what is provided by the
VALUE_LOCATE function, which appeared in IDL 5.3.  If you are not so
up-to-date, then check out the slick replacement for VALUE_LOCATE on
my web page.

 c = value_locate(a, b)


http://cow.physics.wisc.edu/~craigm/idl/idl.html   (under Arrays)

Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response