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!