spline
Interpolate (x,y) data with a cubic spline.
Syntax
yi = spline(x,y,xi)
pp = spline(x,y)
Inputs
- x,y
- The known points with which to create a spline.
- xi
- The domain points at which to interpolate.
Outputs
- yi
- The interpolated y values corresponding to xi.
- pp
- A piecewise polynomial struct.
Example
Interpolate a sine wave.
x = [0:0.2:1]*pi;
y = sin(x);
xi = [0.1:0.2:0.9]*pi;
yi = spline(x,y,xi)
yi = [Matrix] 1 x 5
0.31155 0.80789 0.99993 0.80789 0.31155
Comments
The not-a-knot spline is evaluated when the length of y equals the length of x.
The clamped spline is evaluated when the length of y equals the length of x plus 2. The first and last elements of y are the derivatives at the first and last values of x, so that the indices of the y values are offset by one from the indices of their paired x values.
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.