如何在MATLAB中生成可变大小的随机值矩阵?

时间:2011-03-08 05:34:50

标签: matlab matrix

如何生成行数多于列的随机矩阵?例如,行数是列数的倍数,例如10 columns 500 rows20 columns 1000 rows等......

1 个答案:

答案 0 :(得分:12)

您可以使用RANDRANDI等功能执行此类操作。例如:

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