Spline Toolbox    

Least Squares

If you prefer a least squares approximant, you can obtain it by the statement

in which both the knot sequence knots and the order k of the spline must be provided.

The popular choice for the order is 4, and that gives you a cubic spline. If you have no clear idea of how to choose the knots, simply specify the number of polynomial pieces you want used. For example,

gives a cubic spline consisting of three polynomial pieces. If the resulting error is uneven, you might try for a better knot distribution by using newknt as follows:


  Smoothing Using the Spline Fits