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
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!