Main Content

aptknt

Acceptable knot sequence

Syntax

knots = aptknt(tau,k)
[knots,k] = aptknt(tau,k)

Description

knots = aptknt(tau,k)returns a knot sequence suitable for interpolation at the data sitestauby splines of order k with that knot sequence, providedtauhas at leastk条目,不减少的,满足tau(i)<tau(i+k-1)for alli. In that case, there is exactly one spline of orderkwith knot sequenceknotsthat matches given values at those sites. This is so because the sequenceknotsreturned satisfies the Schoenberg-Whitney conditions

knots(i) < tau(i) < knots(i+k), i=1:length(tau)

with equality only at the extreme knots, each of which occurs with exact multiplicityk.

Iftauhas fewer thankentries, thenkis reduced to the valuelength(tau). An error results iftaufails to be nondecreasing and/ortau(i)equalstau(i+k-1)for somei.

[knots,k] = aptknt(tau,k)also returns the actualkused (which equals the smaller of the inputkandlength(tau)).

Examples

Iftauis equally spaced, e.g., equal tolinspace(a,b,n)for somen>=4, andyis a sequence of the same size astau, thensp = spapi(aptknt(tau,4),tau,y)gives the cubic spline interpolant with the not-a-knot end condition. This is the same cubic spline as produced by the commandspline(tau,y), but in B-form rather than ppform.

Cautionary Note

Iftauis very nonuniform, then use of the resulting knot sequence for interpolation to data at the sitestaumay lead to unsatisfactory results.

Algorithms

The(k-1)-point averagessum(tau(i+1:i+k-1))/(k-1)of the sequencetau, as supplied byaveknt(tau,k), are augmented by ak-foldtau(1)and ak-foldtau(end). In other words, the command gives the same result asaugknt([tau(1),aveknt(tau,k),tau(end)],k), providedtauhas at leastkentries andkis greater than 1.