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 Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by