Functions > Data Analysis > Interpolation and Prediction > Cubic Spline Interpolation
Cubic Spline Interpolation
cspline(vx, vy) or cspline(Mxy, Mz)
lspline(vx, vy) or lspline(Mxy, Mz)
pspline(vx, vy) or pspline(Mxy, Mz)
These functions return a vector vs which interp uses to create a cubic, piecewise polynomial that passes through all the (x, y) data points. The piecewise polynomial has continuous first and second derivatives for any value of x. The resultant spline curve is either cubic (cspline), linear (lspline), or parabolic (pspline) at the endpoints. These functions can also be used for two-dimensional splines, where a surface that corresponds to a cubic polynomial in x and y is passed through a grid of points in such a way that the first and second derivatives of the surface are continuous across each point in each direction.
These functions can be used for two-dimensional splines, where a surface that corresponds to a cubic polynomial in x and y is passed through a grid of points in such a way that the first and second derivatives of the surface are continuous across each point in each direction.
For x values before the first known data point, the functions extrapolate the cubic section between the first two data points. For x values beyond the last known data point, the functions extrapolate the cubic section between the last two data points.
The first three values in the vector output vs are used by the interp function. The remaining elements are the second-derivative coefficients.
Arguments
vx and vy are the vectors of real data values with the same length. Elements of vx, the independent data, are in ascending order.
Mxy is a real n x 2 array of independent data specifying the x and y coordinates along the diagonal of a rectangular grid. You must therefore have the same number of x and y values in your independent data points.
Mz is a real n x n array of data. Mz contains the z values corresponding to x and y values in Mxy.