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

3 次查看(过去 30 天)
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))

采纳的回答

Walter Roberson
Walter Roberson 2021-12-14
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 个评论
omar th
omar th 2021-12-18
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 2021-12-19
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by