natural spline, unmkpp gives 'wrong' answer
Ältere Kommentare anzeigen
I have the following data
x=[-3 -2 1 4 6] y=[2 0 3 1 4]
And I want to calculate the coefficient of the corresponding natural(!) Spline which is given by
$s(x_j) = a_0 + a_1*(x-x_j) + a_2*(x-x_j)^2 + a_3*(x-x_j)^3$
I obtain
| | a_3 | a_2 | a_1 | a_0 | intv | | s0 | 0.5044 | 0 | -2.5044 | 2.0000 | [-3,-2] | | s1 | -0.2831 | 1.5132 | -0.9912 | 0 | [-2,1] | | s2 | 0.2217 | -1.0351 | 0.4430 | 3.0000 | [1,4] | | s3 | -0.1601 | 0.9605 | 0.2193 | 1.0000 | [4,6] |
However when I am using matlab
clear all
x=[-3 -2 1 4 6] y=[2 0 3 1 4] pspl=spline(x,[0 y 0])% a natural spline [breaks,coefs,l,k,d] = unmkpp(pspl)
I obtain
| 2.0595 | -4.0595 | 0 | 2.0000 | | -0.3796 | 2.1190 | -1.9405 | 0 | | 0.3003 | -1.2976 | 0.5238 | 3.0000 | | -0.5387 | 1.4048 | 0.8452 | 1.0000 |
I don't know how to interpret this, the only terms with coincide are that of the right column which must correspond to the terms $a_j$ but for the rest I don't know.
Any help is appreciated.
Thanks
Uwe Brauer
2 Kommentare
Stephen23
am 18 Feb. 2017
@Uwe Brauer: this time I formatted your code for you. In future you can do it yourself by selecting the code text and clicking the {} Code button.
Uwe Brauer
am 18 Feb. 2017
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spline Postprocessing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!