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

1 view (last 30 days)
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 ]

Accepted Answer

Star Strider
Star Strider on 12 Jul 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.
.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!