Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: k (3) Vectors of ones and zeros "combining" together Date: Wed, 18 Jan 2012 02:14:08 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 17 Message-ID: <jf59tg$jbs$1@newscl01ah.mathworks.com> References: <jf510f$nv5$1@newscl01ah.mathworks.com> <jf51ot$q13$1@newscl01ah.mathworks.com> <jf5309$a8$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-04-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1326852848 19836 172.30.248.35 (18 Jan 2012 02:14:08 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Wed, 18 Jan 2012 02:14:08 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:754988 "Apostol" wrote in message <jf5309$a8$1@newscl01ah.mathworks.com>... > but what if I need DIFFERENT combinations? I know for large values of N would be really long/difficult but I would need something that each time generates different combinations so I can evaluate different clusters. > > Thanks :) - - - - - - - - - - This ought to make all possible combinations possible, and they are of equal probability: A = zeros(3,n); p = randperm(N); q = [1:3,ceil(3*rand(1,N-3))]; A(q+3*(p-1)) = 1; The three rows of A are your three vectors. Each row has at least one 1 and each column has exactly one 1. (Note that each time you restart your matlab application it will generate the same sequence of pseudo random numbers unless you use 'randstream' methods.) Roger Stafford