INTERPOL Function
Standard Library function that performs a linear interpolation of a vector using either a regular or irregular grid.
enabled.
Usage
This form is used with a regular grid.
result = INTERPOL(v, n)
This form is used with an irregular grid.
result = INTERPOL(v, x, u)
Input Parameters
For a regular grid:
v—The dependent values of the vector that is to be interpolated. Must be one-dimensional. Can be of any data type except string.
n—The number of interpolated points.
For an irregular grid:
v—The dependent values of the vector that is to be interpolated. Must be one-dimensional. Can be of any data type except string.
x—The independent values of the vector that is to be interpolated. Must have the same number of values as v, and must be monotonic, either increasing or decreasing.
u—The independent values at which interpolation is to occur. Is not necessarily monotonic.
Returned Value
For a regular grid:
result—A vector containing n points interpolated from vector v.
For an irregular grid:
result—A vector containing the same number of values as u.
Keywords
None.
Discussion
The result returned by INTERPOL differs depending on whether a regular or an irregular grid was used, as described below.
-
Regularly-gridded vectors. The vector resulting from INTERPOL used with a regular grid is calculated in the following way, using the FIX function:
-
Irregularly-gridded vectors. The vector resulting from INTERPOL used with an irregular grid has the same number of elements as j and is calculated in the following way, using the FIX function:
result(i) = v(j) + (j – FIX(j)) (v(j + 1) – v(j))
where:
j = i(m–1)/(n–1)
and where:
i is in the range 0 ≤ i ≤ (n–1)
m is the number of points in the input vector v
The output grid horizontal coordinates (abscissae values) are calculated in the following way, using the FLOAT function:
abscissa_value(i) = FLOAT(i)/m
where i is in the range 0 ≤ i < (n – 1).
result(i) = v(j) + (j – FIX(j)) (v(j + 1) – v(j))
where j = u(i).
Example
INTERPOL can be used in signal processing to reconstruct the signal between original samples of data. For example, suppose you have 5 sample data readings, [0, 5, 10, 5, 0], but you need 15 samples.
To get these additional samples, enter the following command:
in_vector = [0, 5, 10, 5, 0] out_vector = INTERPOL(in_vector, 15) PRINT, out_vector, Format='(5F11.6)' ; 0.000000 1.428571 2.857143 4.285714 5.714286 ; 7.142858 8.571428 10.000000 8.571428 7.142858 ; 5.714285 4.285715 2.857143 1.428572 0.000000
The data still starts and ends with zero, and the maximum is still ten, but all the points in between have been recalculated.