MATLAB: How to decide a node in an overlapped area to select which base station

base station selectioncoverage arealink dimensioningmobile phonesrandomly located

I have attached the pic, i have 200 nodes in this scenario and randomly located base stations. In the overlapped area, i want the nodes to calculate the distance between their location and base stations and then decide the shortest path , How can i do that , any ideas? Thank you in advance

Best Answer

Just use the Pythagorean theorem to calculate distances
distances = sqrt((thisX - baseStationXs).^2 + (thisY - baseStationsYs).^2);
% Find the closest one
[closestDistance, indexOfClosestBaseStation] = min(distances);
Not really sure what you mean by "shortest path" but that will give you the index of the base station that is closest to your "test" point.