PPVAL Evaluate piecewise polynomial.
V = PPVAL(PP,XX) returns the value, at the entries of XX, of the
piecewise polynomial f contained in PP, as constructed by PCHIP, SPLINE,
INTERP1, or the spline utility MKPP.
V is obtained by replacing each entry of XX by the value of f there.
If f is scalar-valued, then V is of the same size as XX. XX may be ND.
If PP was constructed by PCHIP, SPLINE or MKPP using the orientation of
non-scalar function values specified for those functions, then:
If f is [D1,..,Dr]-valued, and XX is a vector of length N, then V has
size [D1,...,Dr, N], with V(:,...,:,J) the value of f at XX(J).
If f is [D1,..,Dr]-valued, and XX has size [N1,...,Ns], then V has size
[D1,...,Dr, N1,...,Ns], with V(:,...,:, J1,...,Js) the value of f at
XX(J1,...,Js).
If PP was constructed by INTERP1 using the orientation of non-scalar
function values specified for that function, then:
If f is [D1,..,Dr]-valued, and XX is a scalar, then V has size
[D1,...,Dr], with V the value of f at XX.
If f is [D1,..,Dr]-valued, and XX is a vector of length N, then V has
size [N,D1,...,Dr], with V(J,:,...,:) the value of f at XX(J).
If f is [D1,..,Dr]-valued, and XX has size [N1,...,Ns], then V has size
[N1,...,Ns,D1,...,Dr], with V(J1,...,Js,:,...,:) the value of f at
XX(J1,...,Js).
Example:
Compare the results of integrating the function cos and its spline
interpolant:
a = 0; b = 10;
int1 = quad(@cos,a,b);
x = a:b; y = cos(x); pp = spline(x,y);
int2 = quad(@(x)ppval(pp,x),a,b);
int1 provides the integral of the cosine function over the interval [a,b]
while int2 provides the integral, over the same interval, of the piecewise
polynomial pp that approximates the cosine function by interpolating the
computed x,y values.
Class support for input X and the fields of PP:
float: double, single
See also spline, pchip, interp1, mkpp, unmkpp, splines (The spline Toolbox).