Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

INTERPOL


Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The INTERPOL function performs linear, quadratic, or spline, interpolation on vectors with a regular or irregular grid.

This routine is written in the IDL language. Its source code can be found in the file interpol.pro in the lib subdirectory of the IDL distribution.

Syntax

For regular grids: Result = INTERPOL( V, N [, /LSQUADRATIC] [, /QUADRATIC] [, /SPLINE] )

For irregular grids: Result = INTERPOL( V, X, U [, /LSQUADRATIC] [, /QUADRATIC] [, /SPLINE] )

Return Value

The result is a single- or double-precision floating-point vector, or a complex vector if the input vector is complex.

Arguments

V

An input vector of any type except string.

N

The number of points in the result when both input and output grids are regular. The abscissa values for the output grid will contain the same endpoints as the input.

X

The abscissa values for V, in the irregularly-gridded case. X must have the same number of elements as V, and the values must be monotonically ascending or descending.

U

The abscissa values for the result. The result will have the same number of elements as U. U does not need to be monotonic.

Keywords

LSQUADRATIC

If set, interpolate using a least squares quadratic fit to the equation y = a + bx + cx2, for each 4 point neighborhood (x[i-1], x[i], x[i+1], x[i+2]) surrounding the interval of the interpolate, x[i] £ u < x[i+1].

QUADRATIC

If set, interpolate by fitting a quadratic y = a + bx + cx2, to the three point neighborhood (x[i-1], x[i], x[i+1]) surrounding the interval x[i] £ u < x[i+1].

SPLINE

If set, interpolate by fitting a cubic spline to the 4 point neighborhood (x[i-1], x[i], x[i+1], x[i+2]) surrounding the interval, x[i] £ u < x[i+1].

Note
If LSQUADRATIC or QUADRATIC or SPLINE is not set, the default is to use linear interpolation.

Examples

Create a floating-point vector of 61 elements in the range [-3, 3].

X = FINDGEN(61)/10 - 3 
 
; Evaluate V[x] at each point: 
V = SIN(X) 
 
; Define X-values where interpolates are desired: 
U = [-2.50, -2.25, -1.85, -1.55, -1.20, -0.85, -0.50, -0.10, $ 
   0.30, 0.40, 0.75, 0.85, 1.05, 1.45, 1.85, 2.00, 2.25, 2.75 ] 
 
; Interpolate: 
result = INTERPOL(V, X, U) 
 
; Plot the function: 
PLOT, X, V 
 
; Plot the interpolated values: 
OPLOT, U, result 

Version History

Introduced: Original

See Also

BILINEAR, INTERPOLATE, KRIG2D


Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]