フィルターのクリア

How to get polynomial (2nd order) excel trend–line coefficents in matlab?

5 ビュー (過去 30 日間)
Barbab
Barbab 2019 年 8 月 22 日
編集済み: Guillaume 2019 年 8 月 22 日
If I use [p,S,mu] = polyfit(X,y,2), the coefficents I get are very different from the ones I find in excel. Should I use another function? How can I get the R squared?
Thank you in advance!

回答 (1 件)

Guillaume
Guillaume 2019 年 8 月 22 日
編集済み: Guillaume 2019 年 8 月 22 日
As documented, the [p, S, mu] output of polyfit centers and scales the returned polynomial, so it returns a different polynomial than the [p, S] ouput. If you want the same polynomial as Excel, use the [p, S] output.
As for the value that excel gives you, matlab does not give you that straight, but as explained by John here, you can calculate it:
[p, S] = polyfit(X, y, 2) %if you want the same polynomial as excel.
r2 = 1 - (S.normr/norm(y - mean(y)))^2

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by