How can I obtain the analytical expression (polynomial) of the spline curve from a curve fitting?

11 ビュー (過去 30 日間)
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 件のコメント
Radu Andrei Matei
Radu Andrei Matei 2022 年 3 月 3 日
Thanks, after reading the answers to this question I could understand the ones for that question better.

サインインしてコメントする。

採用された回答

David Goodmanson
David Goodmanson 2022 年 3 月 3 日
編集済み: David Goodmanson 2022 年 3 月 3 日
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 件のコメント
Radu Andrei Matei
Radu Andrei Matei 2022 年 3 月 3 日
Hi, I think I found it. I think using ppval I can find the f(x) value for a given x in the entire spline. Correct me if I'm wrong please.
David Goodmanson
David Goodmanson 2022 年 3 月 3 日
編集済み: David Goodmanson 2022 年 3 月 3 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2022 年 3 月 3 日
編集済み: Matt J 2022 年 3 月 3 日
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,
  1 件のコメント
Radu Andrei Matei
Radu Andrei Matei 2022 年 3 月 3 日
Hi, thank you for your answer, but as I am a big matlab noob I could understand David Goodmanson's answer better.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSplines についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by