Clear Filters
Clear Filters

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

1 view (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 27 Nov 2015
Edited: Star Strider on 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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!