Matrices of random numbers:
The Matrices of random numbers can be generated using the rand and randint functions. The first two arguments in the randint function identify the size of the matrix of random integers. For illustration, the following will create a 2 × 4 matrix of random integers, each of in the range from 10 to 30:
>> randint(2,4,[10,30])
ans =
29 22 28 19
14 20 26 10
For the rand function, when a single value n is passed to it, an n × n matrix will be generated, or passing two arguments will indicate the number of rows and columns:
>> rand(2)
ans =
0.2311 0.4860
0.6068 0.8913
>> rand(1,3)
ans =
0.7621 0.4565 0.0185