Advice needed on Regression functions

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by