title: construct a binary matrix such that each column contains only single "1" and sum of each row is of desired value
body: <p>I want to construct a binary(0s and 1s) matrix satisfying the following constraints: </p>
  
  <ol>
  <li><p>Each column must contains only single binary 1 and rest elements of that column are 0s.</p></li>
  <li><p>The sum of each ROW of matrix should be a desired value.
  For example, given a <code>rowSum</code> vector of [5 7 6 8 .......] then the sum of first row should be 5, sum of second row should be 7 and so on.</p></li>
  <li><p><code>nCol</code>==<code>Sum(rowSum)</code></p></li>
  </ol>
  
  <p>Moreover, I would like to consider <em>several</em> (e.g., 7) matrices satisfying the same conditions.</p>
  
  <p><strong>EDIT:</strong><br/>
  I have tried to write the code and completed the one part of it. The code is: </p>
  
  <pre><code>x=rand(21,50,7);
  for k=1:7
      cons=max(x(:,:,7));
      for i=1:50
          for j=1:21
              if x(j,i,k)==cons(i)
                  x(j,i,k)=1;
              else
                  x(j,i,k)=0;
              end
          end
       end
   end
   x
  </code></pre>