MATRND array or

MATRND array% [[ ,minval%] ,maxval%]


Math Package

This command initialises all of the elements of an integer or floating point array with random numbers. Their default range depends on the type of array: for integer arrays, the values range from -32768 to 32767, whereas for floating point they range between 0 and 1.

MATRND selects the range itself if there is just one parameter, but for integer arrays only, an extended syntax allows you to specify another range (as in the second variant).

If just a maximum value maxval% is specified then values range from 0 to maxval%, if a minimum minval% is additionally given then values range from minval% to maxval%.

MATRND will reject any non-integer parameters for the second syntax.


DIM array%(4,3,2), array(1,2): min%=10
MATRND array
MATRND array%
MATRND array%,100
MATRND array%,min%,100


Like all other MAT… commands, MATRND cannot be compiled with Supercharge or Turbo.


MATRND allows a string array as a parameter. This leads to odd results and can possibly hang the machine.


The random values chosen by MATRND can be influenced by RANDOMISE.