How can I obtain the analytical expression (polynomial) of the spline curve from a curve fitting?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Radu Andrei Matei
am 3 Mär. 2022
Bearbeitet: David Goodmanson
am 3 Mär. 2022
I have extracted data from some graphs (images) and then I curve fitted that data to obtain some spline curves. What I need is the polynomial of those spline, the f(x) that draw the initial graphs, the function that relates the x and y points. How can I do that? Thanks!
3 Kommentare
Akzeptierte Antwort
David Goodmanson
am 3 Mär. 2022
Bearbeitet: David Goodmanson
am 3 Mär. 2022
Hi Radu,
x = 1:10;
y = sin(x).^3;
a = interp1(x,y,'spline','pp')
a =
struct with fields:
form: 'pp'
breaks: [1 2 3 4 5 6 7 8 9 10]
coefs: [9×4 double]
pieces: 9
order: 4
dim: 1
orient: 'first'
>> a.coefs
ans =
0.3050 -1.3676 1.2186 0.5958
0.3050 -0.4525 -0.6016 0.7518
-0.3075 0.4626 -0.5914 0.0028
0.6000 -0.4598 -0.5886 -0.4335
-0.7723 1.3403 0.2920 -0.8818
0.6265 -0.9767 0.6556 -0.0218
-0.7998 0.9029 0.5818 0.2836
0.6101 -1.4966 -0.0119 0.9684
0.6101 0.3337 -1.1748 0.0700
each row is a polynomial in standard Matlab notation, coefficient of x^3 first, coefficient of x^0 last.
a = spline(x,y) does the same thing.
3 Kommentare
David Goodmanson
am 3 Mär. 2022
Bearbeitet: David Goodmanson
am 3 Mär. 2022
Hello Radu,
Yes, each polynomial describes the function for a given little range. Also each polynomial is local in the sense that x = 0 effectively restarts at the beginning of each range. And you are correct, ppval will reconstruct the whole works.
Weitere Antworten (1)
Matt J
am 3 Mär. 2022
Bearbeitet: Matt J
am 3 Mär. 2022
What I need is the polynomial of those spline
A spline consists of many polynomials stuck together, not just one.Also, there are a number of different forms in which spline fits can exist in Matlab, and we don't know which ones you have. If you really need to break down a spline, and it is in the form of a pp structure you could use unmkpp. More likely, you used cftool, in which case you have a cfit object.
Regardless, there is a reason that Matlab doesn't provide you with an analytical form for the spline. It's because far better tools are provided to post-process a fit,
Siehe auch
Kategorien
Mehr zu Splines finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!