bspline(vx, vy, u, n) Returns a vector, used by interp,
of nested arrays containing the coefficients of a B-spline of degree n
for the data in vx and vy, given the
knot values in u. The vector returned becomes the first
argument of the interp function.
interp(vs, vx, vy, x) Returns a B-spline interpolated
y value corresponding to x
using the output vector vs from bspline.
Arguments:
- vx, vy are real vectors of data values of the same
length, vx in ascending order.
- u is a real vector of knots in ascending order, with
n − 1 fewer elements than vx.
Knots are those values where the individual B-spline polynomials fit together,
unlike other splines, where
the knots are forced to be the x values. The first
element in u must be ≤ the
first element in vx. The last element in u
must be ≥ the last element in vx.
- n is an integer equal to 1, 2, or 3, indicating
the degree of the individual piecewise linear (n = 1),
quadratic (n = 2), or cubic (n
= 3) polynomial fits used in the B-spline.
- vs is a vector generated by bspline.
- x is the value of the independent variable at
which you want to evaluate the interpolation curve. For best results, x
should be in the range encompassed by the values of vx.
Notes:
- B-spline interpolation lets you pass a curve through a set of points by
taking three adjacent points and constructing a polynomial of degree n
passing through those points. These polynomials are then strung together at
the knots to form the completed curve. If you have fewer knots than data points,
but can still form a reasonable approximation to y,
then B-splines are a good method for data compression.
- The output of bspline has three components: a flag for interp, an
array whose columns contain the coefficients of the piecewise polynomials,
and an array whose columns contain the endpoints of the intervals specified
by the knots.