how can i found the best linear function representing the following points ???

1 vue (au cours des 30 derniers jours)
x=[ 0 0.6 1.2 1.8 2.4 2.8 ]
f(x)=[ 1.1 2.5 4.9 6.4 9.3 14.1 ]

Réponse acceptée

Star Strider
Star Strider le 12 Juil 2020
Try this:
x=[ 0 0.6 1.2 1.8 2.4 2.8 ]
fx=[ 1.1 2.5 4.9 6.4 9.3 14.1 ]
B = [x(:) ones(size(x(:)))] \ fx(:); % Estimate Parameters
Slope = B(1)
Intercept = B(2)
FitLine = [x(:) ones(size(x(:)))] * B;
figure
plot(x, fx, 'p')
hold on
plot(x, FitLine, '-r')
hold off
grid
A linear fit may not be entirely appropriate, becausse there is an obvious trend in the residuals.
.
  2 commentaires
ammar emad
ammar emad le 12 Juil 2020
OMG . man i really appreciate it and thank you so mush for helping me....
Star Strider
Star Strider le 12 Juil 2020
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by