I keep getting a warning that says polynomial is badly conditioned when I use polyfit() to find the polynomial.

34 ビュー (過去 30 日間)
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.

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 7 月 3 日
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.
  1 件のコメント
Yingyi Huang
Yingyi Huang 2020 年 7 月 3 日
I asked my professor why it can't be 2 degree today, and he says we should have a 10 degree polynomial to increase the agreement between the polynomial equation and the data. If we get an equation for the polynomial, and plug in the same x values as provided, we will receive slightly different y values than the ones provided. We can compare the actual data to the estimated curve with an R^2 correlation value. This values goes between 0 - 1, with 0 being a poor fit and 1 being an identical fit. If we are doing a 2 degree polynomial we will have an R^2 value of ~0.900, while a 10 degree polynomial will have an R^2 of ~0.999, which is more accurate. (We are scaling cone to better print the cone perfectly)

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by