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

Home » Public Forums » archive » Re: VALUE_LOCATE tutorial
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: VALUE_LOCATE tutorial [message #67042 is a reply to message #67035] Wed, 24 June 2009 15:20 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
There's one more important application for Value_Locate that I meant
to include!

(David - you can stick this after the "Using Ranges For Partitioning"
subsection)

- Using Ranges In An Interpolation Scheme -

Another convenient use of this property of Value_Locate is for
interpolation. Most interpolation schemes work by fitting a low-order
polynomial or similar function to the points near the desired
location. How do you efficiently determine which points are the "near
points"? Using Value_Locate!

The simplest example is a linear interpolation between the
neighbouring points: if x[i] <= array[j] <= x[i+1] (where x is
strictly increasing) then the interpolated value is:

interpolated_y[j] = y[i] * (x[i+1]-array[j])/(x[i+1]-x[i]) + y[i+1] *
(array[j]-x[i])/(x[i+1]-x[i])

The trick is to figure out which i to use for a given j... but that's
exactly what Value_Locate does! Here is some simple code that will
calculate this interpolation (I haven't taken care to handle the edge
cases correctly, but see the code of the library function Interpol for
more details):

left = Value_Locate(x, array)
right = left+1
interpolated_y = y[left] * (x[right]-array)/(x[right]-x[left]) + y
[right] * (array-x[left])/(x[right-x[left])

This is equivalent to Interpol(y, x, array).

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Envi virtual machine
Next Topic: Re: IDL Help on Mac OS

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

Current Time: Fri Oct 10 09:36:43 PDT 2025

Total time taken to generate the page: 0.72089 seconds