d-column combinations of matrix A n by n

Hi I'm trying to write an m file which takes a binary sparse matrix A and tests whether this matrix is a d-disjunct matrix.
( definition of D-disjunct : An n × t matrix M over {0, 1} is d-disjunct if d < t and for any one column j and any other d columns j1, j2, . . . , jd, there exists a row i such that Mij =1 and Mijs=0 for s=1,2,...,d.)
(i.e Pick a subset S ( not necessarily together). Then pick a column that is not present in that subset. There will always be i such that 1 in column j and all zero in subset exists.)
To be able to test, I need all d-column combinations and compare them to other columns(which are not part of the combination set).
I started to do this way but I do not know is there a short way to do it.
Matlab code
combinations=nchoosek(length(A(1,:)), d)
for i=1:length(combinations(:,1))
dcombin = A(:,combinations(1,:));
%dunion = find union of all columns in dcombin
%compare it to all other columns
%
My question : How I can get d-column combinations and find its union.
Thank you in advance in case of one answers this question.

 Respuesta aceptada

Bruno Luong
Bruno Luong el 26 de Feb. de 2011
Another way is:
any(A,2)

1 comentario

Jan
Jan el 27 de Feb. de 2011
+1. If I compare the number of characters in the question and in this answer, I register a certain discrepancy.

Iniciar sesión para comentar.

Más respuestas (1)

Bruno Luong
Bruno Luong el 26 de Feb. de 2011
I'm not ths is what you want:
A=rand(10,5)>0.9
% Union of all columns of A
logical(sum(A,2))

1 comentario

Mehmet Candemir
Mehmet Candemir el 27 de Feb. de 2011
thanks. That's the one I found after a while. Though, the second way is better and more elegant.

Iniciar sesión para comentar.

Categorías

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by