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

1 visualizzazione (ultimi 30 giorni)
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 ]

Risposta accettata

Star Strider
Star Strider il 12 Lug 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.
.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by