Clear Filters
Clear Filters

Advice needed on Regression functions

1 view (last 30 days)
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

Accepted Answer

the cyclist
the cyclist on 20 Jun 2011
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 Comment
michael
michael on 21 Jun 2011
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]

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!