Create random matrix (MATLAB)
Afficher commentaires plus anciens
Dear,
I have these initial parameters :
numRows = 216;
numCols = 432;
A = zeros(numRows,numCols);
numOnesPerCol = randi(([2,3]),[1,numCols]);
numOnesPerRow = randi(([5,6]),[numRows,1]);
and I want to create a binary matrix with dimensions (numRows*numCols) that has numOnesPerCol and numOnesPerRow.
How can I do that please
4 commentaires
Hi there ! Can you be a liitle clear?Do you want all the rows of first col have the numonesperrow data or do you want the first col of all the row have numonepercoldata ??
You cant merge your parameter in any way but you can try
numRows = 216;
numCols = 432;
A = zeros(numRows,numCols);
numOnesPerCol = randi(([2,3]),[215,numCols]);
numOnesPerRow = randi(([5,6]),[1,numCols]);
a=[numOnesPerRow ;numOnesPerCol ]
or vice versa
Torsten
le 15 Jan 2022
numOnesPerCol is a row vector (1x432) with only 2's and 3's.
numOnesPerRow is a row vector (1x216) with only 5's and 6's.
So what do you mean by
"I want to create a matrix with dimensions (numRows*numCols) that has numOnesPerCol and numOnesPerRow"
high speed
le 15 Jan 2022
high speed
le 15 Jan 2022
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 15 Jan 2022
Then mask it with two numbers like
output = latinRectangle == 1 | latinRectangle == 2;
Sorry I don't have Latin Rectangle code but there is Latin Square, and maybe Latin Rectangle, code in the File Exchange.
1 commentaire
high speed
le 15 Jan 2022
Catégories
En savoir plus sur Surrogate Optimization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


