How to obtain the piecewise expressions of spline fit obtained using MATLAB's command spapi?
3 views (last 30 days)
Show older comments
I am working on fitting the data using B-form splines. I am using "spapi" command in MATLAB. Here is my code:
x = [0.0 0.3 0.5 0.6 1.0 1.0 0.0 0.2 0.6 0.8];
y = [1.0 0.5 0.9 0.8 0.0 1.0 0.0 0.1 0.2 0.7];
[yy,xx] = meshgrid(y,x); z = sin(xx+yy);
sp = spapi({3,5},{x,y},z)
fnplt(sp)
fnval(sp,[x;y])
I want to obtain the piece wise expressions of the splines. I tried see the documentation of spapi but they haven't mentioned any formulations for those. The function fnval only provide the value at some points, but i want to obtain the expression and calculate it derivatives further.
0 Comments
Answers (1)
Steven Lord
on 22 Sep 2022
i want to obtain the expression and calculate it derivatives further.
Do you need the actual expression, or do you just want to be able to evaluate and differentiate it?
load census
S = spapi(2, cdate, pop);
S2 = fnder(S);
[minYear, maxYear] = bounds(cdate);
Y = minYear:5:maxYear;
plot(cdate, pop, 'o', Y, fnval(S, Y), '-+')
figure
plot(Y, fnval(S2, Y), 'x--')
1 Comment
Muhammad Adeel Ahsan Awan
on 22 Sep 2022
How can i get the piecewise expressions of splines on different intervals?
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!