Products & Services Solutions Academia Support User Community Company

Learn more about Spline Toolbox   

Least Squares

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

sp = spap2(knots,k,x,y);

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,

sp = spap2(3,4,x,y); 

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:

sp = spap2(newknt(sp),4,x,y);
  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS