Can I sort each of these group associated random points SEPARATELY for each point ?

1 visualización (últimos 30 días)
Can I sort these group of assigned point seperatly, which means I want to know exactly the group of RED points (as vectors it is not necessary to plot them) that assigned to blue Pentagon seperately. Thanks in advance
the line that I want to change it
plot([PosUE(inrange,1) PosBSs_x(BSidx(inrange))]', ...
[PosUE(inrange,2) PosBSs_y(BSidx(inrange))]','b');
whole code
ro=1000; % radius of the layout circle
NumBSs=6; % Number of Base stations
NumUEs=50; % Number of users
center=[0 0]; % center of the circle
maxrange = 250; % max range for base stations (stars)
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);
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;
[minD BSidx] = min(D,[],2);
inrange = minD <= maxrange^2;
numinrange = nnz(inrange);
% 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(PosBSs_x,PosBSs_y,'bp','MarkerSize', 12)
plot(PosUE(inrange,1),PosUE(inrange,2),'r.','MarkerSize', 12);
plot(PosUE(~inrange,1),PosUE(~inrange,2),'r.','MarkerSize', 12);
% 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')

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by