randi
Generates random integers.
Syntax
v = randi(imax)
v = randi(imax, n, ...)
v = randi(imax, n, m, ...)
v = randi([imin,imax], ...
Inputs
- imin
- The minimum integer to produce (default: 1).
- imax
- The maximum integer to produce, up to 2^31-1.
- m, n, ...
- The length of each dimension in the output matrix.
Outputs
- v
- The random integers.
Examples
Generate a 3x8 matrix of random integers on the interval [2,8].
rand('seed', 2023);
v = randi([2,8], 3, 8)
v = [Matrix] 3 x 8
4 5 2 7 2 5 5 2
6 6 2 5 3 5 6 5
8 6 2 4 7 6 5 4