MATLAB: D-column combinations of matrix A n by n

combinationsd-disjunctd-sparseMATLABunion

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.

Best Answer

  • Another way is:
    any(A,2)