How to count number of devices in a given area ?
Afficher commentaires plus anciens

Hello everyone, i am trying to compare some traffic models fro machine type communication and i have a problem now. I have a given area 1000x1000 and there are some devices randomly placed in this area and lets say i have 2 base station and radius of the coverage area of those base stations. I want to write such a code that let me color the nodes in that coverage area and give me the number of devices inside? Can anyone help about that? Here i have attached the given scenario. Thank you so much in advance.
Réponse acceptée
Plus de réponses (1)
Guillaume
le 2 Déc 2014
Isn't it as simple as calculating the distance from the device to the base station and comparing that to the radius?
devices = randi([0 999], 100, 2); %100 random devices, col1=x, col2 = y
basestation = [999 0];
radius = 600;
distsquared = sum(bsxfun(@minus, devices, basestation).^2, 2)
inrange = distsquared <= radius.^2;
2 commentaires
Cladio Andrea
le 2 Déc 2014
Mohammad Abouali
le 2 Déc 2014
Cladio, if your coverage area is circular, then Guillaume approach is going to be much faster than using inpolygon. That function is good if you have non-circular coverage.
Catégories
En savoir plus sur Manage Coverage Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!