How can we provide minimum distance i.e. 20 between each random generated node?
Show older comments
No_of_clusters = 25
no_sensor_box = 8
for i=1:no_of_clusters
for j=1:no_sensor_box
Xloc(s)=randi([x_loc1(i)+1,x_loc2(i)-1],1,1);
Yloc(s)=randi(([y_loc1(i)+1,y_loc3(i)]-1),1,1);
s=s+1;
end
end
This code generates nodes at some random locations, but I want the minimum distance (i.e.=20) between two nodes that means the minimum distance between each node are not less than 20. How to provide minimum distance between two nodes in this?
1 Comment
Torsten
on 8 Nov 2017
How is the distance between two nodes s1 and s2 defined ?
d(s1,s2) = sqrt((Xloc(s1)-Xloc(s2))^2+(Yloc(s1)-Yloc(s2))^2)
?
Best wishes
Torsten.
Accepted Answer
More Answers (1)
I think Jan Simon's answer will at least partially solve your problem:
Best wishes
Torsten.
1 Comment
SHUAB KHAN
on 9 Nov 2017
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!