FUNCTION REFERENCE

rand

Uniform random numbers between zero and one.

Uniform random numbers between zero and one.

Syntax

rand()

Syntax

rand(n)

Syntax

rand(m, n)

Syntax

rand([m n])

No size gives a scalar; one scalar size gives a square matrix. Values lie strictly between 0 and 1 and fill columns first. rand, randn and randi share one generator per engine session. Use rng to set the seed. An optional 'double' or 'single' class is accepted. Sizes must fit the matrix and statement limits; higher dimensions must be singleton.

Syntax

rand(..., 'single')

Syntax

rand(..., 'like', single(1))

Example

rand(2, 'single')

Example

rng(0); rand(1,3)   % [0.814724 0.905792 0.126987]

Differences from MATLAB: Legacy generator-state forms are not supported.

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