Re: interpolation question [message #48458 is a reply to message #25895] |
Mon, 24 April 2006 12:04   |
Jo Klein
Messages: 54 Registered: January 2006
|
Member |
|
|
Hi Chen,
VALUE_LOCATE works differently: It returns the location as the interval
in which your value is to be found, vec[location]<=value<vec[location+1]
It's not designed to be a nearest-neighbour-style routine. Granted, the
function name is a bit misleading ...
Cheers,
Jo
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".
>
> Thanks.
>
> Regards,
>
> Chen
>
|
|
|