Drawing a Best Line Fit for some Points

조회 수: 53 (최근 30일)
Hollis Williams
Hollis Williams 2020년 10월 5일
답변: KSSV 2020년 10월 5일
I have collected some experimental data which results in a set of points with x- and y- coordinates, if I put these into a vector what would be the easiest way to plot them on a graph and then draw a best fit straight line through the points?

답변 (1개)

KSSV
KSSV 2020년 10월 5일
Read about polyfit.
p = polyfit(x,y,1) ;
yi = polyval(p,x) ;
plot(x,y,'.r')
hold on
plot(x,yi,'b')

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by