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.

 採用された回答

Bruno Luong
Bruno Luong 2011 年 2 月 26 日

1 投票

Another way is:
any(A,2)

1 件のコメント

Jan
Jan 2011 年 2 月 27 日
+1. If I compare the number of characters in the question and in this answer, I register a certain discrepancy.

サインインしてコメントする。

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2011 年 2 月 26 日

0 投票

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 件のコメント

Mehmet Candemir
Mehmet Candemir 2011 年 2 月 27 日
thanks. That's the one I found after a while. Though, the second way is better and more elegant.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by