Asked by Utpal Bakshi
on 11 Feb 2013

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..

*No products are associated with this question.*

Answer by 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);

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments