MATLAB doing wrong polynomial fitting
Afficher commentaires plus anciens
Hello guys,
I have been doing some fittings lately. For this case I have a set of 55 points from which I'd like to obtain a good fitting. For simplicity I was trying a polynomial fitting with degree = 9. The graph matlab generated was this:

And the coefficients were these:
Linear model Poly9:
f(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 +
p5*x^5 + p6*x^4 + p7*x^3 + p8*x^2 + p9*x + p10
Coefficients (with 95% confidence bounds):
p1 = -5.012e-21 (-8.177e-21, -1.848e-21)
p2 = 2.014e-17 (7.065e-18, 3.322e-17)
p3 = -3.562e-14 (-5.94e-14, -1.184e-14)
p4 = 3.637e-11 (1.14e-11, 6.135e-11)
p5 = -2.363e-08 (-4.032e-08, -6.943e-09)
p6 = 1.013e-05 (2.772e-06, 1.749e-05)
p7 = -0.002864 (-0.005003, -0.0007243)
p8 = 0.5149 (0.1193, 0.9105)
p9 = -53.42 (-95.63, -11.21)
p10 = 2437 (457.4, 4417)
Goodness of fit:
SSE: 0.003537
R-square: 0.9978
Adjusted R-square: 0.9974
RMSE: 0.008865
So far, so good, the results should be between 1 and 0.3, however when i tested a random value in the polynomial itself, like 300, the result was above 3, indicating the fitting was wrong. Here is the graph generated using Maple with the coefficients from Matlab:

As we can see, the graphs are totally not connected. Honestly, I have never seen something like this and i have spent all day trying to figure this out. The fitting was done with Robust = off and no center and scale (I've tried that too, experiencing the same problems). I hope you guys can help me.
2 commentaires
Walter Roberson
le 12 Déc 2015
Please post the x and y coordinates.
Pedro Rafael Guaraldi da Silva
le 12 Déc 2015
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Polynomials dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!