ppval - Evaluate piecewise polynomial

Syntax

v = ppval(pp,xx)

Description

v = ppval(pp,xx) returns the value of the piecewise polynomial f, contained in pp, at the entries of xx. You can construct pp using the functions interp1, pchip, spline, 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, v is of the same size as xx. xx may be N-dimensional.

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 orienatation of non-scalar function values specified for that function, then:

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).

Examples

Compare the results of integrating the function cos

a = 0; b = 10;
int1 = quad(@cos,a,b)

int1 =
   -0.5440

with the results of integrating the piecewise polynomial pp that approximates the cosine function by interpolating the computed values x and y.

x = a:b; 
y = cos(x);
pp = spline(x,y);
int2 = quad(@(x)ppval(pp,x),a,b)

int2 =
   -0.5485

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.

See Also

mkpp, spline, unmkpp

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS