Given number of base stations and users , how can I accociate each user to the nearest base station?

6 views (last 30 days)
I deployed the BSs and Users randomly according to Binomial Point Process, and I assumed to connect each user to nearest BS. So, how can I accociate these users in matlab.
thanks in advance
ro=500; % radius of the layout circle
NumBSs=10; % Number of Base stations
NumUEs=50; %Number of users
center=[0 0]; % center of the circle
theta_BSs=2*pi*(rand(NumPoints,1)); % distributed random number of Base stations
g = 0.5 * ro + 0.5 * ro * rand(NumBSs,1);
PosBSs_x=center(1)+g.*cos(theta_BSs);
PosBSs_y=center(2)+g.*sin(theta_BSs);
theta1 = rand(NumUEs, 1) * 2*pi; % distributed random number of Users
r1 = ro * sqrt(rand(NumUEs, 1));
PosUE = [r1 .* cos(theta1(:)) + center(1),r1 .* sin(theta1(:)) + center(2)];
% Initial plot objects
hfig = figure('Color', 'w');
hax=axes('parent',hfig);
% Plot of deploying points
hdots=plot(PosBSs_x(:,1),PosBSs_y(:,1),'bp',PosUE(:,1),PosUE(:,2),'r.','MarkerSize', 12);
grid on
hold(hax, 'on')
axis(hax, 'equal')
% Plot the layout as circles
t = linspace(0, 2*pi);
plot(ro * cos(t) + center(1),ro * sin(t) + center(2))

Accepted Answer

Walter Roberson
Walter Roberson on 14 Dec 2021
pdist2() the coordinates of the stations against the coordinates of the base stations to find the distance from each station to each base station. Then min() along the appropriate axes to determine the index to use.
  5 Comments
omar th
omar th on 18 Dec 2021
But I deployed the drone Base stations (Nodes) and ground base station (gNB=Node) seperately, so when I tried to gether them, I got an error " Dimensions of arrays being concatenated are not consistent"
How could you help me with this issue ?
Thanks for your response
Walter Roberson
Walter Roberson on 19 Dec 2021
For the purposes of pdist2(), you should be using rows in which each row represents one point. If some of your coefficients are represented by columns instead of rows, transpose them.
If you base stations and ground base station are represented by different spatial dimensions (for example, 2D for base stations but 3d for ground base stations), then you need to convert the coordinates to all be the longer length, perhaps by padding with zero.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!