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,pchipormakima. xq- Points of evaluation, any size.
Output arguments
v- Values of
ppatxq, with the shape ofxqfor scalar-valuedpp.
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