csapi
Cubic spline interpolation
Description
Note
For a simpler but less flexible method to interpolate cubic splines,
try the Curve Fitter app or the fit
function and see
About Smoothing Splines.
returns the ppform of a cubic spline s with knot sequence
pp
= csapi(x
,y
)x
that takes the values y(:,j)
at
x(j)
for j=1:length(x)
. The values
y(:,j)
can be scalars, vectors, matrices, and ND-arrays.
The function averages the data points with the same data site and then sorts
them by their sites. With x
the resulting sorted data sites,
the spline s
satisfies the not-a-knot end conditions, such as
where D3s is the third derivative of s.
If x
is a cell array of sequences x1
,
..., xm
of lengths n1
, ...,
nm
, then y
is an array of size
[n1,...,nm]
(or of size [d,n1,...,nm]
if the interpolant is d
-valued). In that case,
pp
is the ppform of an m
-cubic spline
interpolant s to such data. In particular,
with and .
To perform operations on this interpolating cubic spline, such as evaluation,
differentiation, plotting, use the pp structure. For more information, see the
fnval
, fnder
, fnplt
functions.
returns the values of the smoothing spline evaluated at the points
values
= csapi(x
,y
,xx
)xx
. This syntax is the same as
fnval(csapi(x,y),xx)
.
This command is essentially the MATLAB® function spline
, which, in turn, is a
stripped-down version of the Fortran routine CUBSPL
in
PGS, except that csapi
(and now also
spline
) accepts vector-valued data and can handle gridded
data.
Examples
Input Arguments
Output Arguments
Algorithms
csapi
is an implementation of the Fortran routine
CUBSPL
from PGS.
The algorithm constructs and solves the relevant tridiagonal linear system using the MATLAB sparse matrix capability.
The algorithm also uses the not-a-knot end condition, forcing the first and second polynomial piece of the interpolant to coincide, as well as the second-to-last and the last polynomial piece.
Version History
Introduced in R2006b