MATLAB: Connecting a line from the first data point to the last data point

line

I have a 2D scatter plot. I am trying to create a line that connects from the very first data point to the very last data point only. I would appreciate any help. I have a total of 40 data points.

Best Answer

x=1:10;
y=rand(size(x));
scatter(x,y);
line(x([1 end]),y([1,end]))