MATLAB: How to do a line progression of line trend.

arrayplottingprogression

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.

Best Answer

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