rand
Uniformly distributed random numbers
Syntax
Description
returns a random scalar drawn from
the uniform distribution in the interval (0,1).X
= rand
returns an X
= rand(sz1,...,szN
)sz1
-by-...-by-szN
array of random numbers
where sz1,...,szN
indicate the size of each dimension. For example,
rand(3,4)
returns a 3-by-4 matrix.
generates numbers from random number stream X
= rand(s
,___)s
instead of the default
global stream. To create a stream, use RandStream
. You
can specify s
followed by any of the input argument combinations in
previous syntaxes.
Examples
Input Arguments
Output Arguments
More About
Tips
The sequence of numbers produced by
rand
is determined by the internal settings of the uniform pseudorandom number generator that underliesrand
,randi
, andrandn
. You can control that shared random number generator usingrng
.