Given number of base stations and users , how can I accociate each user to the nearest base station?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
omar th
am 14 Dez. 2021
Kommentiert: Walter Roberson
am 19 Dez. 2021
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))
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 14 Dez. 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 Kommentare
Walter Roberson
am 19 Dez. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!