Re: interpolation question [message #48457 is a reply to message #25895] |
Mon, 24 April 2006 12:09   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
chen123.dian@gmail.com wrote:
> Hi,
>
> Thanks so much for all suggestions here.
>
> I am so wonder that why IDL has no simple function like MATLAB's
> 'interp2'. Another problem is for value_locate. Some suggestions
> mentioned to use value_locate. Here is a example to show my problem.
>
> IDL> vec = [2.0, 5.0, 8.0, 10.0]
> IDL> print, vec
> 2.00000 5.00000 8.00000 10.0000
> IDL> loc = VALUE_LOCATE(vec, [0.0, 4.5, 5.0, 6.0, 12.0])
> IDL> print, loc
> -1 0 1 1 3
>
> We can see the value of "4.5" corresponds to index location of "0".
> Actually, the value of "4.5" should correspond to index location of "1"
> because the value of "4.5" is closer to the value of "5.0" having index
> location of "1".
From the documentation:
<quote>
Result = VALUE_LOCATE ( Vector, Value [, /L64 ] )
Return Value
Each return value, Result [i], is an index, j, into Vector, corresponding to the interval
into which the given Value [i] falls. The returned values are in the range -1 £ j £ N-1,
where N is the number of elements in the input vector
</quote>
I presume in IDL-documentation-land "£" means "≤".
So the results you've got seem to be correct.
paulv
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
|
|
|