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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Star Strider
Star Strider am 27 Nov. 2015
Bearbeitet: Star Strider am 27 Nov. 2015
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.
  4 Kommentare
hadi
hadi am 27 Nov. 2015
Thank You very much. Hope you the best.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by