Linear fit of the points
11 次查看(过去 30 天)
显示 更早的评论
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!

0 个评论
采纳的回答
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!