MATLAB Function Reference
ppval

Evaluate piecewise polynomial.

Syntax

• ```v = ppval(pp,xx)
v = ppval(xx,pp)
```

Description

```v = ppval(pp,xx) ``` returns the value at the points `xx` of the piecewise polynomial contained in `pp`, as constructed by `spline` or the spline utility `mkpp`.

```v = ppval(xx,pp) ``` returns the same result but can be used with functions like `fminbnd`, `fzero` and `quad` that take a function as an argument.

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(@ppval,a,b,[],[],pp)

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`

 pow2 prefdir