Can we assign or associate the random points only that located inside the a specific range ?

1 visualización (últimos 30 días)
Is there a way to assign the RED points which are located within the STARS range (assume STARS have range (as circle) is 100m raduis), while the RED points that are located out of the STAR range let them associated to the ''BLACK + which is range the outer circle that has raduis 1000m'' ?
ro=1000; % 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))

Respuesta aceptada

DGM
DGM el 14 de Feb. de 2022
Here's a start. I used different colors for clarity, but you can change that to whatever you want.
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 = 1000;
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;
inrange = any(D <= maxrange^2,2);
numinrange = nnz(inrange);
% Initial plot objects
hfig = figure(2);
hax=axes('parent',hfig);
% Plot of deploying points
hdots(1) = plot(PosBSs_x,PosBSs_y,'bp','MarkerSize', 12); hold on
if numinrange > 0
hdots(2) = plot(PosUE(inrange,1),PosUE(inrange,2),'g.','MarkerSize', 12);
end
if numinrange < NumUEs
hdots(3) = plot(PosUE(~inrange,1),PosUE(~inrange,2),'r.','MarkerSize', 12);
end
% 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')
  8 comentarios
DGM
DGM el 17 de Mzo. de 2022
You should be able to just do a logical combination of the two conditions:
inrange = (mindistD >= maxrange^2) & (mindistD<= maxrangeD2^2);
omar th
omar th el 31 de Mzo. de 2022
Thank you so much,
Can I sort these group of assigned point seperately, 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
in this line
plot([PosUE(inrange,1) PosBSs_x(BSidx(inrange))]', ...
[PosUE(inrange,2) PosBSs_y(BSidx(inrange))]','b');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deploy to .NET Applications Using MWArray API en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by