![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1307500/image.png)
Read the value of the trend line from an X-value
조회 수: 4 (최근 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1307500/image.png)
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!