how to do a line progression of line trend.

10 vues (au cours des 30 derniers jours)
jesus escareno
jesus escareno le 28 Déc 2017
Commenté : Star Strider le 29 Déc 2017
So i have a line plot from an two arrays X = [52.5, 81.25, 86.25, 106.5]; and Y= [787.5, 1228.13, 1361.25, 1796.26, 1233.75];. How am I able to map their progression if the trend where to keep on going.

Réponse acceptée

Star Strider
Star Strider le 28 Déc 2017
First, you cannot, because your ‘X’ vector is (1x4) and your ‘Y’ vector is (1x5). Deleting the last element of ‘Y’, fitting a linear model, and extrapolating, try this:
X = [52.5, 81.25, 86.25, 106.5];
Y= [787.5, 1228.13, 1361.25, 1796.26];
B = [X(:) ones(size(X(:)))]\Y(:);
Xv = linspace(-100, 250);
Yv = [Xv(:), ones(size(Xv(:)))] * B;
figure(1)
plot(X, Y, 'pg')
hold on
plot(Xv, Yv, '-r')
hold off
grid
  4 commentaires
jesus escareno
jesus escareno le 29 Déc 2017
Okay I got it. Does clarify how the whole code works.
Thanks.
Star Strider
Star Strider le 29 Déc 2017
As always, my pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by