ppval

Evaluates a piecewise polynomial.

Category: Mathematics > Interpolation

Syntax

v = ppval(pp, xq)

Evaluates the piecewise polynomial pp at the points xq.

Description

For each query point ppval finds the interval of pp.breaks that contains it and evaluates the polynomial of that interval in the local variable. Points beyond the first or last break point use the polynomial of the end interval, so the function extrapolates rather than returning NaN.

Input arguments

pp
Structure created by mkpp, spline, pchip or makima.
xq
Points of evaluation, any size.

Output arguments

v
Values of pp at xq, with the shape of xq for scalar-valued pp.

Example

Spline through four points of x^3

pp = spline(0:3, [0 1 8 27]);
ppval(pp, [0.5 1.5 2.5])
Output
ans = 1×3

    0.1250    3.3750   15.6250

See also

mkpp unmkpp spline pchip polyval