Linear fit of the points

조회 수: 12 (최근 30일)
James Lorringer
James Lorringer 2015년 9월 9일
댓글: Star Strider 2015년 9월 9일
Hello, I got a plot (attached). Suppose the plot is simply from:
plot (x,y);
How can I get a linear least squares fit for these three points (they are actually not on one line) and then get the specific x values on the fit when I give certain y values, for example:
2.5:0.025:2.55
Thank you very much!

채택된 답변

Star Strider
Star Strider 2015년 9월 9일
편집: Star Strider 2015년 9월 9일
Probably the easiest way is to use polyfit and polyval. Use an order 1 polynomial to get a straight-line fit.
EDIT To get the x-values for y-values using polyfit for a straight-line fit, this will work:
b = polyfit(x, y, 1);
x = (y-b(2))/b(1);
  댓글 수: 2
James Lorringer
James Lorringer 2015년 9월 9일
Thank you!
Star Strider
Star Strider 2015년 9월 9일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by