pchip

Interpolate (x,y) data with a Hermite cubic polynomial.

Syntax

yi = pchip(x,y,xi)

pp = pchip(x,y)

Inputs

x,y
The known points with which to create a spline.
Type: double
Dimension: vector
xi
The domain points at which to interpolate.
Type: double
Dimension: vector

Outputs

yi
The interpolated y values corresponding to xi.
pp
A piecewise polynomial struct.
See mkpp for details.

Example

Interpolate a sine wave.

x = [0:0.2:1]*pi;
y = sin(x);
xi = [0.1:0.2:0.9]*pi;
yi = pchip(x,y,xi)
yi = [Matrix] 1 x 5
0.32527  0.82555  0.95106  0.82555  0.32527

Comments

When y is a matrix, the function operates along the last dimension, which is the row dimension in the 2D case. This is the opposite convention from interp1.