Create random matrix (MATLAB)
Show older comments
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 Comments
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
on 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
on 15 Jan 2022
high speed
on 15 Jan 2022
Accepted Answer
More Answers (1)
Image Analyst
on 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 Comment
high speed
on 15 Jan 2022
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

