How can we provide minimum distance i.e. 20 between each random generated node?
이전 댓글 표시
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
Torsten
2017년 11월 8일
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.
채택된 답변
추가 답변 (1개)
I think Jan Simon's answer will at least partially solve your problem:
Best wishes
Torsten.
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!