I keep getting a warning that says polynomial is badly conditioned when I use polyfit() to find the polynomial.
35 views (last 30 days)
Show older comments
x y
0 0
0 13.46857
1 14.40183
2 15.30334
3 16.17611
4 17.02267
5 17.84523
6 18.6457
7 19.42574
8 20.18682
(... ....more, till x = 2000).
These are teh data I import
This is the error I got. I don't get it why. When I tested with 0 is not 12.5, instead, it's always larger. Other students can get 12.5. I don't know where the problem is.
0 Comments
Answers (1)
Walter Roberson
on 3 Jul 2020
If your x values range from 0 to 2000, then you cannot numerically justify a degree 10 polynomial fit. Consider that for x = 1, the leading term C10*x^10 would be C10*1^10 -> C10 and that for x = 2000, the leading term C10*x^10 would be C10*2000^10 -> C10 * 1.024E33 . The difference between those is so large that the x = 1 version is effectively meaningless.
You can try using centering and rescaling; see the polyfit() documentation. But the main thing you should do is not use a degree 10 polynomial to fit; the results are typically numerically meaningless.
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!