8

How can I generate a random matrix with more rows than columns? For example, with the number of rows being a multiple of the number of columns, like 10 columns 500 rows, or 20 columns 1000 rows, etc...

1 Answer 1

12

You can do these sorts of things using functions like RAND and RANDI. For example:

nCols = randi([10 20]);   %# A random integer between 10 and 20
nRows = nCols*50;         %# Number of rows is a multiple of number of columns
mat = rand(nRows,nCols);  %# A matrix of random values between 0 and 1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.