Cubic spline data interpolation
yy = spline(x,Y,xx)
pp = spline(x,Y)
yy = spline(x,Y,xx)
uses a
cubic spline interpolation to find yy
, the values
of the underlying function Y
at the values of the
interpolant xx
. For the interpolation, the independent
variable is assumed to be the final dimension of Y
with
the breakpoints defined by x
. The values in x
must
be distinct.
The sizes of xx
and yy
are
related as follows:
If Y
is a scalar or vector, yy
has
the same size as xx
.
If Y
is an array that is not a
vector,
If xx
is a scalar or vector, size(yy)
equals [d1,
d2, ..., dk, length(xx)]
.
If xx
is an array of size [m1,m2,...,mj]
, size(yy)
equals [d1,d2,...,dk,m1,m2,...,mj]
.
pp = spline(x,Y)
returns
the piecewise polynomial form of the cubic spline interpolant for
later use with ppval
and the spline utility unmkpp
. x
must
be a vector with distinct values. Y
can be a scalar,
a vector, or an array of any dimension, subject to the following conditions:
If x
and Y
are
vectors of the same size, the not-a-knot end conditions are used.
If x
or Y
is
a scalar, it is expanded to have the same length as the other and
the not-a-knot end conditions are used. (See Exceptions (1) below).
If Y
is a vector that contains
two more values than x
has entries, the first and
last value in Y
are used as the endslopes for the
cubic spline. (See Exceptions (2) below.)
If Y
is
a vector that contains two more values than x
has
entries, the first and last value in Y
are used
as the endslopes for the cubic spline. If Y
is
a vector, this means
f(x) = Y(2:end-1)
df(min(x)) = Y(1)
df(max(x)) = Y(end)
If Y
is
a matrix or an N
-dimensional array with size(Y,N)
equal
to length(x)+2
, the following hold:
f(x(j))
matches the value Y(:,...,:,j+1)
for j=1:length(x)
Df(min(x))
matches Y(:,:,...:,1)
Df(max(x))
matches Y(:,:,...:,end)
Note
You can also perform spline interpolation using the |
[1] de Boor, C., A Practical Guide to Splines, Springer-Verlag, 1978.