need help in random sampling of all possible combinations

2 views (last 30 days)
Hi all,
I have an input file (input.txt) in tab separated format. A small part of the input file is as follows:
Gr1 Gr2 Gr3 Gr4 ..............
row1 1 1 1 0 ..............
row2 0 1 0 1 ...............
row3 1 1 0 1 ..............
...................
.................
From this input,random sampling of all possible Group combinations needed to be taken, and print in a output file. From the above input, the output file should be as follows (the three columns are: Number of groups used in analysis, Group names, Number shared between these groups;;; Shared number are measured if 1 is present in all the measuring groups).
output:
2 Gr1-Gr2 2
2 Gr1-Gr3 1
2 Gr1-Gr4 1
2 Gr2-Gr3 1
2 Gr2-Gr4 2
2 Gr3-Gr4 0
3 Gr1-Gr2-Gr3 1
3 Gr1-Gr2-Gr4 1
3 Gr1-Gr3-Gr4 0
3 Gr2-Gr3-Gr4 0
4 Gr1-Gr2-Gr3-Gr4 0
Any idea how to do it??? thanks in advance..

Answers (1)

Youssef  Khmou
Youssef Khmou on 11 Feb 2013
hi,
You can create a cell in which you can store all your variables (2,Gr2,Gr4,...) (cell because you have heterogeneous data), and then you can obtain all possible combinations by using the function perms :
An example using cell A with 3 elements :
A{1}='Utpal';
A{2}='that is you';
A{3}=3.14458741;
B=perms(A);

Categories

Find more on Creating and Concatenating Matrices 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!