Spline Toolbox | ![]() ![]() |
Knot Choices
It is, in fact, possible to specify explicitly just where the spline interpolant should have its breaks, using the command
in which the sequence knots
supplies, in a certain way, the breaks to be used. For example, recalling that we had chosen y
to be sin(x)
, the command
provides a cubic Hermite interpolant to the sine function, namely the piecewise cubic function, with breaks at all the x(i)
's, that matches the sine function in value and slope at all the x(i)
's. This makes the interpolant continuous with continuous first derivative but, in general, it has jumps across the breaks in its second derivative. Just how does this command know which part of the data value array [y cos(x)]
supplies the values and which the slopes? Notice that the data site array here is given as [x x]
, i.e., each data site appears twice. One of the first things done in spapi
is to check whether the data site array is nondecreasing and to reorder it to make it so if need be, in which case the data value array is reordered in the same way. In this way, y(i)
is associated with the first occurrence of x(i)
, and cos(x(i))
is associated with the second occurrence of x(i)
. The data value associated with the first appearance of a data site is taken to be a function value; the data value associated with the second appearance is taken to be a slope. If there were a third appearance of that data site, the corresponding data value would be taken as the second derivative value to be matched at that site. See The B-form for a discussion of the command augknt
used here to generate the appropriate "knot sequence".
![]() | General Spline Interpolation | Smoothing | ![]() |