fit data with a line

Respuestas (1)

Ameer Hamza
Ameer Hamza el 19 de Jun. de 2020

0 votos

Try something like this
x = linspace(0, 1, 100);
y = 3*x + 2 + rand(size(x));
pf = polyfit(x, y, 1);
y_pred = polyval(pf, x);
r2 = rsquare(y, y_pred); % R-squared
sse = sum((y-y_pred).^2); % SSE

2 comentarios

Sarah Smith
Sarah Smith el 19 de Jun. de 2020
is rsqaure a function?
Ameer Hamza
Ameer Hamza el 19 de Jun. de 2020

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 19 de Jun. de 2020

Comentada:

el 19 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by