Some confusion on polyfit?

2 ビュー (過去 30 日間)
Jesse
Jesse 2014 年 8 月 21 日
コメント済み: Star Strider 2014 年 8 月 21 日
Greetings all,
This one is throwing me for a loop. So I have some data that I was preforming a linear fit on with the basic fit tool GUI, and I receive the coefficients
Coefficients:
p1 = -0.0068338
p2 = 3.9156
Cool - so I wanted to double verify if these numbers were good, so I used the polyfit command:
[fitResults1,S1,mu1] = polyfit(xdata1,ydata1,1)
but I get different coefficients:
-0.1138 2.4694
So, I generated code from the plot to show me what command they are using to get the first sent of coefficients, and they are using polyfit like me, except it's of the form:
fitResults1 = polyfit(xdata1, ydata1, 1)
Notice it's not in brackets as described in http://www.mathworks.com/help/matlab/ref/polyfit.html
but why are the coefficients so different between the two? I double checked everything (i.e., if xdata1 was the x data from my plot and ydata1 was the y data from my plot, and it was).
Did I stumble on a bug?
Thanks!

採用された回答

Star Strider
Star Strider 2014 年 8 月 21 日
Not a bug at all.
When you used:
[fitResults1,S1,mu1] = polyfit(xdata1,ydata1,1)
you invoked the centreing and scaling of x that polyfit does if you ask for the mu output. You’re fitting different x-data.
  8 件のコメント
Jesse
Jesse 2014 年 8 月 21 日
Ok cool thanks Star! I will try that!
Star Strider
Star Strider 2014 年 8 月 21 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by