lininterp

Linear interpolation function.

Syntax

lininterp(old_x, old_y, new_x)

Argument

old_x
The x vector of the curve to be interpolated.
old_y
The y vector of the curve to be interpolated.
new_x
A scalar or a vector containing x values for which new y values are to be calculated.

Example

Templex Expression Result
{lininterp( {0,3,5,8},
            {2,5,9,7}, 6.5)}
8
{lininterp( {0,3,5,8}, 
            {2,5,9,7} ,1:5:1)}
3,4,5,7,9
Curve Math Vectors Result
x = new_x

y = lininterp(c1.x, c1.y, new_x)

Given c1, a curve is created with interpolated y values at each point of new_x.
new_x can be from a different curve created using range operator 2-37 or with the Read command.

Comments

The lininterp function uses linear interpolation to resample data. lininterp estimates a y-value for each element in new_x such that the new points lie on or near the curve defined by old_x, old_y. old_x, old_y and new_x must have the same number of elements.

If old_x is not entirely increasing and new_x is a scalar, the first value of old_x is used. If new_x is a vector, old_x must be entirely increasing.

If new_x is a scalar, the result is a scalar. If new_x is a vector, the result is a vector with the same number of elements as new_x.

lininterp performs interpolation only. All values of new_x must lie between the minimum of old_x and the maximum of old_x.