Re: a random matrix of zeros and ones with exactly N ones
- From: Jos <x@xxx>
- Date: Fri, 15 Sep 2006 11:15:18 -0400
Omid wrote:
How can I generate a random matrix of a defined size with elements
zero or one with exactly M ones? For example a 4*5 matrix with 9
ones
and 11 zeros. I want it to be completely random such that the
generated matrix be able to span the space of all possible
permutations of zeros and ones (M ones)in the matrix.
See NTRUE:
<http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10924&objectType=FILE>
A = ntrue(9,4,5) ;
It uses randperm to fill the entries, as in the other replies.
hth
Jos
.
- References:
- Prev by Date: Re: binary output from neural network
- Next by Date: Image processing + matlab book
- Previous by thread: Re: a random matrix of zeros and ones with exactly N ones
- Next by thread: Re: a random matrix of zeros and ones with exactly N ones
- Index(es):
Relevant Pages
|