Could anyone tell me how to different combinations with respect to 6 users on the same coding.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2018년 3월 23일
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!