Re: Need help with value_locate and interpolation [message #38945] |
Fri, 02 April 2004 14:42 |
Yunxiang Zhang
Messages: 19 Registered: October 2003
|
Junior Member |
|
|
check out the motley IDL library for MGH_LOCATE(). That might be what you
want.
Yunxiang
On 1 Apr 2004, Leslie Welser wrote:
> I'm having some trouble with using the value_locate function. Let's
> say I have a vector with 10 elements, and I want to find the
> "interpolated" array index for a particular value. I know how to
> interpolate the vector, but I can't find a way to return the index as
> a float and not an integer. In other words, given a certain value of
> the array, I would like to find a way to return the information that
> that interpolated value is at an index of, say, 4.27. Is there a
> simple way to do this?
> Thanks,
> Leslie
>
|
|
|
Re: Need help with value_locate and interpolation [message #38948 is a reply to message #38945] |
Fri, 02 April 2004 09:21  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
Ben Tupper wrote:
>
> Leslie Welser wrote:
>
>> I'm having some trouble with using the value_locate function. Let's
>> say I have a vector with 10 elements, and I want to find the
>> "interpolated" array index for a particular value. I know how to
>> interpolate the vector, but I can't find a way to return the index as
>> a float and not an integer. In other words, given a certain value of
>> the array, I would like to find a way to return the information that
>> that interpolated value is at an index of, say, 4.27. Is there a
>> simple way to do this?
>> Thanks,
>> Leslie
>
> Hello,
>
> I can't understand what you are after, at least, I don't see how an
> interpolated value could have an "index" into the original. Could you
> take another swing at your question - maybe with pseudo-code of what you
> want to do.
I think that what he wants is a linear interpolation between the
discrete values that would be provided by a where(). Thus:
x = [0.5, 1.2, 3.6, 93.2]
where(x eq 1.2) gives 1, where(x eq 3.6) gives 2. Since 2.4 is exactly
1/2 way between 1.2 and 3.6, then interp_index(x,2.4) would give a value
exactly 1/2 way between 1 and 2: 1.5.
|
|
|
Re: Need help with value_locate and interpolation [message #38949 is a reply to message #38948] |
Fri, 02 April 2004 09:20  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
Leslie Welser wrote:
> I'm having some trouble with using the value_locate function. Let's
> say I have a vector with 10 elements, and I want to find the
> "interpolated" array index for a particular value. I know how to
> interpolate the vector, but I can't find a way to return the index as
> a float and not an integer. In other words, given a certain value of
> the array, I would like to find a way to return the information that
> that interpolated value is at an index of, say, 4.27. Is there a
> simple way to do this?
You might look at the function tabinv.pro at
ftp://idlastro.gsfc.nasa.gov/pub/pro/math/tabinv.pro
which first uses VALUE_LOCATE to find the two integer indicies which
bracket the supplied value, and then linear interpolates between the two
indicies to return a floating point value.
--Wayne Landsman
|
|
|
Re: Need help with value_locate and interpolation [message #38950 is a reply to message #38949] |
Fri, 02 April 2004 09:06  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Fri, 02 Apr 2004 12:00:54 -0500, Ben Tupper wrote:
> Leslie Welser wrote:
>
>> I'm having some trouble with using the value_locate function. Let's
>> say I have a vector with 10 elements, and I want to find the
>> "interpolated" array index for a particular value. I know how to
>> interpolate the vector, but I can't find a way to return the index as
>> a float and not an integer. In other words, given a certain value of
>> the array, I would like to find a way to return the information that
>> that interpolated value is at an index of, say, 4.27. Is there a
>> simple way to do this?
>> Thanks,
>> Leslie
>
> Hello,
>
> I can't understand what you are after, at least, I don't see how an
> interpolated value could have an "index" into the original. Could you
> take another swing at your question - maybe with pseudo-code of what you
> want to do.
I think he probably means his data is monotonic, in which case
something like:
frac=interpol(findgen(n_elements(data)),data,value)
will work. Here `value' can be a vector (and should be, if you have
multiple values to search).
JD
|
|
|
Re: Need help with value_locate and interpolation [message #38951 is a reply to message #38950] |
Fri, 02 April 2004 09:00  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Leslie Welser wrote:
> I'm having some trouble with using the value_locate function. Let's
> say I have a vector with 10 elements, and I want to find the
> "interpolated" array index for a particular value. I know how to
> interpolate the vector, but I can't find a way to return the index as
> a float and not an integer. In other words, given a certain value of
> the array, I would like to find a way to return the information that
> that interpolated value is at an index of, say, 4.27. Is there a
> simple way to do this?
> Thanks,
> Leslie
Hello,
I can't understand what you are after, at least, I don't see how an
interpolated value could have an "index" into the original. Could you
take another swing at your question - maybe with pseudo-code of what you
want to do.
Ben
|
|
|