フィルターのクリア

Advice needed on Regression functions

1 回表示 (過去 30 日間)
michael
michael 2011 年 6 月 20 日
Hey everyone,
I am doing a project for physics lab where I have to analyze data for of a Frank Hertz experiment current vs. accelerating voltage for Neon. I need to do a polynomial regression curve fitting for the following data values of A against the model function a*x^2+b*x+c:
X = [57.0, 58.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 65.9] Y = [-29.4, -30.195, -33.858, -36.262, -39.612, -43.236, -47.460, -52.589, -57.356]
I tried polyeval() with an order = 2 fit; however, it seems that the data is so bad that the value of a was a > 0 instead of a<0 .
I was wondering if anyone could provide advice about what I should do next. Is their a way in matlab's regression functions to assign specific conditionals or boundaries for the parameters? Or can someone suggest another statistical fit that would produce a maximum?
Sincerly,
Michael

採用された回答

the cyclist
the cyclist 2011 年 6 月 20 日
Rather than just describing what you did, I suggest you post your code. Maybe you made some syntax error.
This looks pretty good to me:
X = [57.0, 58.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 65.9];
Y = [29.4, 30.195, 33.858, 36.262, 39.612, 43.236, 47.460, 52.589, 57.356]
p = polyfit(X,Y,2)
figure
hold on
plot(X,Y,'.')
plot(X,p(1)*X.^2+p(2)*X+p(3))
Ordinarily, one could use polyval() in that last step, but I wanted to illustrate exactly how the coefficients work out.
  1 件のコメント
michael
michael 2011 年 6 月 21 日
Yeah in hindsight I realized what I provided would work because I forgot to add a negative sign to all the Y values. I correct it above and now below:
X = [57.0, 58.0, 60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 65.9];
Y = [-29.4, -30.195, -33.858, -36.262, -39.612, -43.236, -47.460, -52.589, -57.356]

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by