fit data with a line
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ok
1 commentaire
Réponses (1)
Ameer Hamza
le 19 Juin 2020
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 commentaires
Ameer Hamza
le 19 Juin 2020
Oh! I forgot to mention, rsquare is from this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/34492-r-square-the-coefficient-of-determination
Voir également
Catégories
En savoir plus sur Least Squares dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!