Could anyone tell me how to different combinations with respect to 6 users on the same coding.

1 view (last 30 days)
If there are 4 users I want to combine users into groups under the conditions:
  1. condition 1->users present in one group should not be present in other group.
  2. 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.

Accepted Answer

Image Analyst
Image Analyst on 23 Mar 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 Comment
Prabha Kumaresan
Prabha Kumaresan on 23 Mar 2018
thanks.for the code
c = combnk(1:4,2)
c =
3 4
2 4
2 3
1 4
1 3
1 2
could you tell me how to group the combinations such that number present in one combination should not be present in other combination.

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!