SPLINE Cubic spline data interpolation.
PP = SPLINE(X,Y) provides the piecewise polynomial form of the
cubic spline interpolant to the data values Y at the data sites X,
for use with the evaluator PPVAL and the spline utility UNMKPP.
X must be a vector.
If Y is a vector, then Y(j) is taken as the value to be matched at X(j),
hence Y must be of the same length as X -- see below for an exception
to this.
If Y is a matrix or ND array, then Y(:,...,:,j) is taken as the value to
be matched at X(j), hence the last dimension of Y must equal length(X) --
see below for an exception to this.
YY = SPLINE(X,Y,XX) is the same as YY = PPVAL(SPLINE(X,Y),XX), thus
providing, in YY, the values of the interpolant at XX. For information
regarding the size of YY see PPVAL.
Ordinarily, the not-a-knot end conditions are used. However, if Y contains
two more values than X has entries, then 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 N-D array with SIZE(Y,N) equal to LENGTH(X)+2, then
f(X(j)) matches the value Y(:,...,:,j+1) for j=1:LENGTH(X), then
Df(min(X)) matches Y(:,:,...:,1) and Df(max(X)) matches Y(:,:,...:,end).
x = 0:10; y = sin(x);
xx = 0:.25:10;
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy)
用三次多项式插值可以使得曲线更加平滑,一阶和二阶连续