Best Fit Line for Parabola
조회 수: 66 (최근 30일)
이전 댓글 표시
I am trying to make a best fit line for a negative parabola, but when I use polyfit(x,y,2) and plot it I get the following image. Any tips?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1133470/image.png)
댓글 수: 1
답변 (1개)
Star Strider
2022년 9월 22일
Try something like this —
x = [0; 0.019; 0.036];
y = [0.015; 0.25; 0.05];
p = polyfit(x, y, 2)
xv = linspace(min(x), max(x));
yv = polyval(p,xv);
figure
plot(x, y, 'o')
hold on
plot(xv, yv, '-r')
hold off
xlabel('x')
ylabel('y')
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!