ppval

Piecewise polynomial evaluation.

Syntax

yi = ppval(pp, xi)

Inputs

pp
A piecewise polynomial struct.
See mkpp for details.
xi
The values at which to evaluate the polynomial.
The polynomial is defined in powers of (xi-lb), where lb is the lower bound in pp.breaks of the piece containing each xi. lb is set to pp.breaks(1) if xi is below the range and it is set to pp.breaks(pieces) if xi is above the range.
Type: double
Dimension: scalar | vector | matrix

Outputs

yi
The evaluated polynomial values.
Each piecewise polynomial in the pp struct is evaluated for each element in xi. The dimensions of yi are [pp.dim, length(xi)] for a vector xi, and [pp.dim, size(xi)] for a matrix xi.

Example

breaks = [10, 20, 30, 40, 50];
L = length(breaks) - 1;
order = 3;
coefs = zeros(L, order);
coefs(1, :) = [2, 3, 4];
coefs(2, :) = [3, 4, 5];
coefs(3, :) = [4, 5, 6];
coefs(4, :) = [6, 7, 8];
pp = mkpp(breaks, coefs);
yi = ppval(pp, [24, 31])
yi = [Matrix] 1 x 2
69  15