How can I generate a variably-sized matrix of random values in MATLAB?
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...
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
精彩评论