Info

This question is closed. Reopen it to edit or answer.

# what functions should I look at to achieve [triples] as i need it 5*3 where number of AP is not repeated

1 view (last 30 days)
sara alaraby on 13 Feb 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
What functions should I look at to achieve [triples] as I need it 5*3 where number of AP is not repeated
clc;
clear all
close all
% --------------------------------------------------------
% user = PPP
% BS = PPP
% **********************************************************************
% Step 1) User deployment:
area = 100*100e-6;
user_intensity = 600; % number of users that you want
center = [50e-3 ,50e-3]; % center coordinates of the circle
radius =50e-3 ; % radius of the circle
%% nusers = poissrnd(user_intensity*area); % random angle
nusers = 60;
r = 2*radius*rand(nusers,2);
Ux = r(:, 1); % x-coordinates of users
Uy = r(:, 2); % y-coordinates of users
intensity_of_BS = 1000; % lambda of the PPP
%% npoints = poissrnd(area*intensity_of_BS); % create a PPP
npoints=15;
pproc = 2*radius*rand(npoints,2);
BSx = pproc(:, 1); % x-coordinates of base stations
BSy = pproc(:, 2); % y-coordinates of base stations
%% calculating distance Between BS (Update)
points= [BSx BSy];
for xIndex = 1 : length(BSx)
for yIndex = 1 : length(BSy)
distances(xIndex, yIndex) = sqrt((BSx(xIndex)-BSx(yIndex))^2 + (BSy(xIndex)-BSy(yIndex))^2);
end
end
[distances, I] = sort(distances,'descend');
%%Group
td = distances;
tripidx = 0;
triples = [];
std = size(td);
while nnz(td(:) ~= 0 & ~isnan(td(:))) >= 2
[~, maxidx] = max(td(:));
[maxr, maxc] = ind2sub(std, maxidx);
td(maxr, maxc) = nan;
[~, maxc2] = max(td(maxr, :));
tripidx = tripidx + 1;
triples(tripidx, :) = [maxr, maxc, maxc2];
td([maxr maxc maxc2], :) = nan;
td(:, [maxr maxc maxc2]) = nan;
end

### Community Treasure Hunt

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

Start Hunting!