Could anyone tell me how to different combinations with respect to 6 users on the same coding.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Prabha Kumaresan
el 23 de Mzo. de 2018
Comentada: Prabha Kumaresan
el 23 de Mzo. de 2018
If there are 4 users I want to combine users into groups under the conditions:
- condition 1->users present in one group should not be present in other group.
- condition 2->users need to form different combinations of groups, since there are 4 users. Say for example, (12,34) can be one combination. The next one can be (13,24), and other one can be (14,23).
code
unused_rows=1:4
while ~isempty(unused_rows)
N_UE_rows=2;
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
The above code works, but I can get only one combination of results. Can anyone help me to get the output of all three combinations.
0 comentarios
Respuesta aceptada
Image Analyst
el 23 de Mzo. de 2018
If you have the Statistics and Machine Learning Toolbox, try this:
>> c = combnk(1:6, 4)
c =
3 4 5 6
2 4 5 6
2 3 5 6
2 3 4 6
2 3 4 5
1 4 5 6
1 3 5 6
1 3 4 6
1 3 4 5
1 2 5 6
1 2 4 6
1 2 4 5
1 2 3 6
1 2 3 5
1 2 3 4
1 comentario
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!