MATLAB: How to plot a line between the corresponding point on the x y palne

plotting

Hi All,
I have the first set of points that are defined as follows:
N=5;
Xmax=200;
Ymax=200;
AP_X=Xmax*rand(1,N);%APs random X possitions in meters.
AP_Y=Ymax*rand(1,N);%APs random Y possitions in meters.
And I have the other set of points that are defined as follows:
AU_X=Xmax*rand(1,N);%Users random X possitions in meters.
AU_Y=Ymax*rand(1,N);%Users random Y possitions in meters.
Now, I want to draw a line between the corresponding points from the two sets (i.e. point1 with point1, point2 with point2, and so on)
Thank you.

Best Answer

If I understand correctly what you are asking, this will work:
N=5;
Xmax=200;
Ymax=200;
AP_X=Xmax*rand(1,N);%APs random X possitions in meters.
AP_Y=Ymax*rand(1,N);%APs random Y possitions in meters.
AU_X=Xmax*rand(1,N);%Users random X possitions in meters.
AU_Y=Ymax*rand(1,N);%Users random Y possitions in meters.
figure(1)
plot([AP_X; AP_Y], [AU_X; AU_Y], '-k')
hold on
plot(AP_X, AU_X, 'bp')
plot(AP_Y, AU_Y, 'r^')
hold off
EDIT — Replaced original code with code matching ‘fig.jpg’ in hadi’s first Comment.