

The knot sequence is obtained by applying aptknt to an appropriate subsequence of x. Note: the knots are computed in a separate algorithm and should be used for the interpolator, getting a good fit is not the question here. spap2(l,k,x,y), with l a positive integer, returns the B-form of a least-squares spline approximant, but with the knot sequence chosen for you. I am stuck with this, unable to see where is the problem with this data sample. but here the result is completely erroneous. I don't expect a nice fit, but at least the spline fit sticks with the knots.

Using MATLAB, you can solve technical computing problems faster than with traditional programming languages, such as C, C, and Fortran.

If you only want to get a cubic spline approximation consisting of l polynomial pieces, use instead sp spap2 (l,4,x,y) If the resulting approximation is not satisfactory, try using a larger l.
#SPAP2 MATLAB 2012 CODE#
The code is quite simple, I cannot figure out what is the problem: spgood = spap2(knots_zY, 4, ec, Y) The actual data is the blue curve, red circles are the knots I am using and yellow curve is the display of the cubic spline curve. I encounter strange results from spap2 on some data:
