Function Reference
— Function File: pp = mkpp (x, p)
— Function File: pp = mkpp (x, p, d)

Construct a piece-wise polynomial structure from sample points x and coefficients p. The ith row of p, p (i,:), contains the coefficients for the polynomial over the i-th interval, ordered from highest to lowest. There must be one row for each interval in x, so rows (p) == length (x) - 1.

You can concatenate multiple polynomials of the same order over the same set of intervals using p = [ p1; p2; ...; pd ]. In this case, rows (p) == d * (length (x) - 1).

d specifies the shape of the matrix p for all except the last dimension. If d is not specified it will be computed as round (rows (p) / (length (x) - 1)) instead.

See also: unmkpp ppval spline

Demonstration 1

The following code

 # linear interpolation
 x=linspace(0,pi,5)'; 
 t=[sin(x),cos(x)];
 m=diff(t)./(x(2)-x(1)); 
 b=t(1:4,:);
 pp = mkpp(x, [m(:),b(:)]);
 xi=linspace(0,pi,50);
 plot(x,t,"x",xi,ppval(pp,xi));
 legend("control","interp");

Produces the following figure