Drawing a Best Line Fit for some Points

53 visualizaciones (últimos 30 días)
Hollis Williams
Hollis Williams el 5 de Oct. de 2020
Respondida: KSSV el 5 de Oct. de 2020
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?

Respuestas (1)

KSSV
KSSV el 5 de Oct. de 2020
Read about polyfit.
p = polyfit(x,y,1) ;
yi = polyval(p,x) ;
plot(x,y,'.r')
hold on
plot(x,yi,'b')

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by