How to find analytic expression for B-spline curve
15 views (last 30 days)
Show older comments
Suppose I have a set of points (x,y), I can use
sp=spap2(3,4,x,y);
to fit a smooth curve to my data, and that curve consists of 3 cubic polynomials joined at knots. Now the output of this gives 6 coefficients. I originally thought I ought to have 12 coefficients for the 3 cubic polynomials.
Q1: Why are there 6 and not 12? Is this because of conditions on the functions and derivatives at knots?
Q2: As the points are being estimated by a curve with 3 cubics I want to be able to write the curve as a linear combination of these 3 functions, but how do I do this if there are not enough coefficients? I want something like
y=a0+a1x+a2x^2+a3x^3 + b0+b1x+b2x^2+b3x^3 + c0+c1x+c2x^2+c3x^3
Any help would be greatly appreciated.
0 Comments
Answers (2)
Elizabeth Reese
on 23 Aug 2017
When you are executing the command
>> sp = spap2(3,4,x,y);
you are computing the B-form of a spline of order 4 with 3 polynomial pieces and knot locations chosen for you. The spline has 2 continuous derivatives.
The B-form of a spline is representing the spline in terms of a basis of B-splines. The formulation of these basis functions can be found at the following link.
The coefficients that are returned from the "spap2" function are the coefficients for this basis. This is explained further at the following link.
You can play with the B-spline basis functions using the "bspligui" GUI in MATLAB.
The definition of the spline still stands, independent of the form. They are piecewise polynomials, not a closed form for the entire interval.
0 Comments
Yipeng Tang
on 28 Apr 2019
You can use fn2fm fuction to transform sp from 'bp' form to 'pp' form.
eg.
sp = spap2(augknt([x(1) x(length(x))],4),4,x,y)
pp = fnplt(sp);
...
z = pp.coefs(1)*(tt-x(length(x))).^3+ pp.coefs(2)*(tt-x(length(x))).^2+ pp.coefs(3)*(tt-x(length(x)))+pp.coefs(4);
z is what you want
0 Comments
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!