spapi
Spline interpolation
Syntax
Description
returns the spline f (if any) of order spline
= spapi(knots
,x
,y
)
k = length(knots) - length(x)
knots
for which (*) f(x(j)) = y(:,j), all j.
x
are the same, then:
with and Dmf the m-th derivative of f. In this case, the r-fold repetition of a site z in x
corresponds to the prescribing of value and the first r – 1 derivatives of f at z. To match the average of all data values with the same data instead, call spapi
with an additional fourth argument.
The data values, y(:,j)
, can be scalars, vectors, matrices, or ND-arrays.
spapi(
, with k
,x
,y
)k
a positive integer, specifies the desired spline order, k
. In this case the spapi
function calls the aptknt
function to determine a workable, but not necessarily optimal, knot sequence for the given sites x
. In other words, the command spapi(k,x,y)
has the same effect as the more explicit command spapi(aptknt(x,k),x,y)
.
spapi({knork1,...,knorkm},{x1,...,xm},y)
returns the B-form of a tensor-product spline interpolant to gridded data. Here, each knorki
is either a knot sequence, or a positive integer specifying the polynomial order used in the i
-th variable. The spapi
function then provides a corresponding knot sequence for the i
-th variable. Further, y
must be an (r+m
)-dimensional array, with y(:,i1,...,im)
the datum to fit at the site [x{1}(i1),...,x{m}(im)]
, for all i1
, ..., im
. In contrast to the univariate case, if the spline is scalar-valued, then y
can be an m
-dimensional array.
spapi(...,'noderiv')
with the character vector or string scalar 'noderiv'
as a fourth argument, has the same effect as spapi(...)
except that data values sharing the same site are interpreted differently. With the fourth argument present, the average of the data values with the same data site is interpolated at such a site. Without it, data values with the same data site are interpreted as values of successive derivatives to be matched at such a site, as described above, in the first paragraph of this Description.
Examples
Input Arguments
Output Arguments
Limitations
The given (univariate) knots and sites must satisfy the Schoenberg-Whitney conditions for the interpolant to be defined. If the site sequence x
is nondecreasing, then
with equality possible at knots
(1) and knots
(end
)). In the multivariate case, these conditions must hold in each variable separately.
Algorithms
The function calls spcol
to provide the almost-block-diagonal collocation matrix (Bj,k(x)) (with repeats in x
denoting derivatives, as described above), and slvblk
solves the linear system (*), using a block QR factorization.
The function fits gridded data, in tensor-product fashion, one variable at a time, taking advantage of the fact that a univariate spline fit depends linearly on the values that are being fitted.
Version History
Introduced in R2006b