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.
採用された回答
その他の回答 (1 件)
Bruno Luong
2011 年 2 月 26 日
I'm not ths is what you want:
A=rand(10,5)>0.9
% Union of all columns of A
logical(sum(A,2))
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!