Create random matrix (MATLAB)
Mostra commenti meno recenti
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 Commenti
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
il 15 Gen 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
il 15 Gen 2022
high speed
il 15 Gen 2022
Risposta accettata
Più risposte (1)
Image Analyst
il 15 Gen 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 Commento
high speed
il 15 Gen 2022
Categorie
Scopri di più su Surrogate Optimization in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


