Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Combinatioral Matrix
Date: Wed, 10 Oct 2012 18:38:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <k54fah$k24$1@newscl01ah.mathworks.com>
References: <k53cs0$agp$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1349894289 20548 172.30.248.38 (10 Oct 2012 18:38:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 10 Oct 2012 18:38:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:780355

"SULE" wrote in message <k53cs0$agp$1@newscl01ah.mathworks.com>...
> Hello,
> I need to create a matrix seems this
> 
>                       x1  .................... x6 ................... x12    (variable)
>  1                    1    1    1   1   1    1    1  1  0  0  0  0  
>  2                    1    1    1   1   1    1    1  0  1  0  0  0  
> .                      .    .     .     .    .     .    .   .   .  . .   . .
> .                      .     .    .    .    .   .    .    . . . . . . . . . . 
> C(m,n)=495      0   0    0   0  1   1   1   1  1  1  1  1  1 
> 
>  m= # of variable =12= # of columns
>  n =# of constraint = 8
> c(m,n) = # of rows
> c(12,8) = 495
> There should be a combination to create a matrix includes in a row, eight '1' and four'0'.
> I am very new at MATLAB. If you can help me, I will appreciate.
> 
> Sule ERYURUK
- - - - - - - - - -
 P = nchoosek(1:m,n);
 r = size(P,1);
 C = zeros(r,m);
 C(sub2ind(size(C),repmat((1:r)',n,1),P(:))) = 1;

Roger Stafford