FUNCTION REFERENCE

randi

Uniform random integers in an inclusive range.

Uniform random integers in an inclusive range.

Syntax

randi(imax)

Syntax

randi(imax, m, n)

Syntax

randi([imin imax], [m n])

The scalar limit means 1 through imax. A pair gives inclusive lower and upper limits. Limits must be finite integers with absolute value below 2^53 and imin <= imax; a scalar imax must be at least 1. Sizes follow rand: no size gives a scalar and one scalar size gives a square matrix. Output is double, with optional 'double' accepted; higher dimensions must be singleton.

Example

rng(0); randi(10,1,4)   % [9 10 2 10]

Differences from MATLAB: Other output classes are not supported.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.