#Matlab
if i have a matrix 6*6
which gave me info about the distance between all AP
I need to make 3 groups each group consists of 2 AP where AP not repeated in each group depend on the distance
Ex: i will start from AP no. 1 if i select it with AP no.2 as the dist. between the is large
so the second step i will check the 2nd group starting from AP3 & so on
CAN ANY one hwo can i design it by matlab code
Thanks all

6 comentarios

Walter Roberson
Walter Roberson el 21 de En. de 2019
Please say more about how you choose which two AP to group together ?
sara alaraby
sara alaraby el 23 de En. de 2019
i need to start from Ap no 1 chosse Ap depend on the longest disthemance between
Walter Roberson
Walter Roberson el 23 de En. de 2019
Is the rule that at any one point, you select the lowest numbered unpaired AP as the start, and find the unpaired AP that is furthest away to pair with it?
I ask because the order you go through the APs matters. AP 2 might be the furthest AP from AP 1, but AP 1 might not be the furthest AP from AP 2.
sara alaraby
sara alaraby el 26 de En. de 2019
yes, this is my rule
sara alaraby
sara alaraby el 1 de Feb. de 2019
yes dear this is my rule
Image Analyst
Image Analyst el 3 de Feb. de 2019
sara, youi keep forgetting to attach your data, thus delaying a solution.

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de En. de 2019
Editada: Walter Roberson el 2 de Feb. de 2019

0 votos

td = YourDistanceMatrix;
pairidx = 0;
pairs = [];
while nnz(td(:) ~= 0 & ~isnan(td(:))) >= 2
std = size(td);
[maxd, maxidx] = max(td(:));
[maxr, maxc] = ind2sub(std, maxidx);
pairidx = pairidx + 1;
pairs(pairidx, :) = [maxr, maxc];
td(maxr, maxc) = nan;
td(maxc, maxr) = nan;
end
In the above code, distance entries can be nan for forbidden connections, and distances of 0 are ignored under the assumption that they indicate a point connecting to itself (which is not always true: in theory two AP could be a the same location, and this code will refuse to pair them together even if they are the "furthest" remaining APs.)
Because of the possibility of nans and extra 0s, the number of rows output in pairs will not necessarily be the same as half of the number of access points.

11 comentarios

sara alaraby
sara alaraby el 1 de Feb. de 2019
Dear There is an error in line :
[maxr, maxc] = sub2ind(std, maxidx);
Any support please
[maxr, maxc] = ind2sub(std, maxidx);
sara alaraby
sara alaraby el 1 de Feb. de 2019
Dear
The pairs result on your code is matrix 20*2 , this not acceptable
I need to make only 3 groups so pair will be matrix 3*2 as AP not repeated,
can you help me to write the code like this ?
Thanks laot
td = YourDistanceMatrix;
pairidx = 0;
pairs = [];
while nnz(td(:) ~= 0 & ~isnan(td(:))) >= 2
std = size(td);
[maxd, maxidx] = max(td(:));
[maxr, maxc] = ind2sub(std, maxidx);
pairidx = pairidx + 1;
pairs(pairidx, :) = [maxr, maxc];
td([maxr maxc], :) = nan;
td(:, [maxr maxc]) = nan;
end
sara alaraby
sara alaraby el 3 de Feb. de 2019
Dear ;
Can you help me ihwo can i update in this code if i have a matrix 15*15 a need to create 5 groups each one consists of 3 AP where AP not repeated
Thanks
You need to define the rule for grouping. You cannot simply extend to "three closest": A might be closest to B, and second closest to C, but that does not mean that B is close to C
B+++++A++++++C
+
+
+
+
+
+
D
D is closer to B or C than B is close to C.
sara alaraby
sara alaraby el 4 de Feb. de 2019
Dear;
i need to start from AP no 1 then choose 2 AP which are fartest from it , in case of we select AP (5,10)
the second step we will start from AP 2 then chosse 2 AP with it and so son,
where AP not repeated
can you support to write like this
Walter Roberson
Walter Roberson el 4 de Feb. de 2019
Note that the two AP that are furthest from the first node, could be very close to each other. That means that the order you go through is important. Are you sure that is what you want?
After you have done
[maxr, maxc] = ind2sub(std, maxidx);
then look for the maximum in td in row maxr but that is not located at (maxr, maxc) (so, the second greatest distance involving that same row.) Find its column and record that as part of pairs. Make sure you nan the entire corresponding row and column.
sara alaraby
sara alaraby el 4 de Feb. de 2019
dear i can't understand well what you mean
can you write such a code for me please
td = YourDistanceMatrix;
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
I doubt this is what you want, but it is what you asked for and confirmed that you wanted.
I suspect that what you want is closer to finding the set of three that together cover the greatest triangular area.

Iniciar sesión para comentar.

Más respuestas (1)

sara alaraby
sara alaraby el 4 de Feb. de 2019

0 votos

Dear;
yes dear i'm sure that this what i want
can you support me please
thanks

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Preguntada:

el 21 de En. de 2019

Comentada:

el 4 de Feb. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by