# If I scattered number of points, can I sort or (determine) the exact location for each random point in matlab ?

1 view (last 30 days)
omar th on 20 Feb 2022
Commented: omar th on 21 Feb 2022
if I distribute number of points randomly (NumUEs), so these random points associated with another random points (NumBSs=2; Number of Nodes OR Base stations), can I determine the positions of associated points. as explained in the code below, I assigned number of users to number of nodes (base stations). my question is that can I determine the locations of these assigned point to this node (which means let the node learn the location of it's associated points) ??
ro=1000; % radius of the layout circle
NumBSs=2; % Number of Base stations
NumUEs=50; % Number of users
center=[0 0]; % center of the circle
maxrange = 250; % max range for base stations (stars)
h=100; %Hieght of BS
theta_BSs=2*pi*(rand(NumBSs,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);
PosDrone = [PosBSs_x PosBSs_y];
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)];
% find which UE points are within range of a BS
%D = (PosUE(:,1)-PosBSs_x.').^2 + (PosUE(:,2)-PosBSs_y.').^2;
PosUAV3D = [PosDrone, h * ones(NumBSs,1)];
D = (PosUE(:,1)-PosUAV3D(:,1).').^2 + (PosUE(:,2)-PosUAV3D(:,2).').^2; % UAV to UE distances
[minD, BSidx] = min(D,[],2);
inrange = minD <= maxrange^2; %if min distance between UEs and drone less
%or equal to the range of drone which is 200m, we consider these distances
%in the range.
%numinrange = nnz(inrange);
%Pos_B_range = sqrt(sum(PosgNB .^ 2, 2));
% Initial plot objects
hfig = figure(2);
hax=axes('parent',hfig);
% Plot of deploying points
hold on
plot([PosUE(inrange,1) PosBSs_x(BSidx(inrange))]',[PosUE(inrange,2) PosBSs_y(BSidx(inrange))]','b');
plot([PosUE(:,1) repmat(center(1),NumUEs,1)]',[PosUE(:,2) repmat(center(2),NumUEs,1)]','k');
plot(center(1),center(2),'k.','MarkerSize', 20) % plot fixed gNB as black dot
plot(PosBSs_x,PosBSs_y,'bp','MarkerSize', 12) % plot drones as blue pentagon
plot(PosUE(inrange,1),PosUE(inrange,2),'r.','MarkerSize', 12); % plot UEs in range of drones as red dots
plot(PosUE(~inrange,1),PosUE(~inrange,2),'r.','MarkerSize', 12); % plot UEs in range of gNB as red dots
% Plot the layout as circles
t = linspace(0, 2*pi);
plot(ro * cos(t) + center(1),ro * sin(t) + center(2))
grid on
hold(hax, 'on')
axis(hax, 'equal')
omar th on 21 Feb 2022
well, I want to tomove BS toward X or Y users based on the signal quality according to my algorithm but I dont know how to lmake BS learn the locations of its associated users in matlab

R2018a

### Community Treasure Hunt

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

Start Hunting!