random deployment of nodes

5 views (last 30 days)
Shamsuddeen Abdullahi
Shamsuddeen Abdullahi on 20 Apr 2019
Edited: John D'Errico on 20 Apr 2019
How can I randomly deploy nodes (points) into say 6 different clusters within an M by M (100 by 100) region. the clusters (regions) are within the 100 by 100 region. i cannot think of a way to start.....
How to form the clusters (regions) then deploys nodes (points)?
Please help

Accepted Answer

John D'Errico
John D'Errico on 20 Apr 2019
Edited: John D'Errico on 20 Apr 2019
I don't see the problem. You don't start by solving the entire problem in one line of code. You start by going as slowly as you need to go. But you start. Just start.
Pick n cluster locations. (ncluster=6 here.) you would probably do that using a tool like rand. READ THE HELP FOR RAND, if you don't know how to sample points between two fixed limits.
You might decide to test to see if two cluster centers fall too closely to each other. If they do. then just repeat the cluster location step again, until you are happy with the result. That would just be a while loop. You can determine the distances between all locations from each other in one step useing a tool like pdist.
Once you have those cluster centers, then generate random offsets to each cluster location. You might use a tool lile randn or rand to determine those offsets.
The point being, when you have a problem that is too large and complex for you to solve, outline a set of discrete steps that will solve the task. Then find ways of solving each step, ONE at a time. Verify that your solution works for the current step in this sequence of sub-tasks. Then go on to the next step. Finally, put it all together. Your problem will be solved, and since you know that each step was correct, the entire task is now done.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!