From: ltaboada T. Antelo on 15 Jun 2010 03:53 Hi all: I want to create a matrix of a given dimension MxN composed by zeros and ones with the following characteristics: 1. For each row i only a 1 located in a random column j must exist (all other position (i,j) must be zero) 2. The sum of all row i for a given column j must be equal to 1 (i.e only a position with 1 must exist in each column). 2. The sum of all column j for a given column i must be equal to 1 (i.e only a position with 1 must exist in each row). An example of I want can be the following 5x5 matrix: 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 or 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 Waiting for your help. Thank you in advance Luis
From: us on 15 Jun 2010 04:00 "ltaboada T. Antelo" <luistabo(a)yahoo.es> wrote in message <hv7bgv$bqr$1(a)fred.mathworks.com>... > Hi all: > > I want to create a matrix of a given dimension MxN composed by zeros and ones with the following characteristics: > > 1. For each row i only a 1 located in a random column j must exist (all other position (i,j) must be zero) > 2. The sum of all row i for a given column j must be equal to 1 (i.e only a position with 1 must exist in each column). > 2. The sum of all column j for a given column i must be equal to 1 (i.e only a position with 1 must exist in each row). > > An example of I want can be the following 5x5 matrix: > > 0 0 0 1 0 > 1 0 0 0 0 > 0 1 0 0 0 > 0 0 1 0 0 > 0 0 0 0 1 > > or > > 1 0 0 0 0 > 0 0 1 0 0 > 0 0 0 0 1 > 0 0 0 1 0 > 0 1 0 0 0 > > Waiting for your help. > > Thank you in advance > > Luis one of the many solutions n=5; % <- size of your mat... m=eye(n); rix=randperm(n); m=m(rix,:); us
|
Pages: 1 Prev: biochemical engineering Next: Poor Images from CCD camera |