Given two positions on a map, draw a straight line between them when a condition is met
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I am simulating a cellular cell with N users whose positions x,y are generated randomly. I have a matrix L (NxN) where L(i,j) (the indices i and j represents two users) could be zero or have a different value. I would like to plot the positions ( I ve done it) but also to plot a line (a link) between the users i,j whose L(i,j) is different from 0.. How can I?
0 Kommentare
Antworten (1)
Gaurav Garg
am 30 Jan. 2020
Hi,
Assuming that you have properly declared and defined posx and posy vectors (containing x and y coordinates of users) and L matrix (as told in the question), you may find the below attached code helpful:
figure();
for i =1:size(A,1)
for j =1:size(A,2)
if A(i,j)~=0
plot( [posx(i) posx(j)], [posy(i) posy(j)] );
hold on;
end
end
end
hold off;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Other Formats finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!