
Read the value of the trend line from an X-value
2 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I have displayed measurement data as scatter and created the trend lines with polyval and polyfit. Is there a way to read the value of the trend line from an X-value?
Many thanks in advance!
0 个评论
采纳的回答
Image Analyst
2023-2-26
See my attached polyfit demo.

Once you have the formula coefficients, you can either use the equation (like in the title of the plots above), or use the function polyval to get the estimated/fitted y value.
2 个评论
Image Analyst
2023-2-26
编辑:Image Analyst
2023-2-26
It's a variable (vector) in the program called "coefficients". Open up the code and look at it. It's exceptionally well commented. Specifically
% Do the regression with polyfit to fit a cubic polynomial.
cubicCefficients = polyfit(x, y, 3)
I also show how to get the equation using those coefficients.
% Get the estimated values with polyval()
yFit = polyval(cubicCefficients, xFit);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!