Given number of base stations and users , how can I accociate each user to the nearest base station?
49 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);
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');
% Plot of deploying points
% Plot the layout as circles
t = linspace(0, 2*pi);
plot(ro * cos(t) + center(1),ro * sin(t) + center(2))
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.