<< moc_prepad Matlab/Octave Compatibility toolbox moc_range >>

Matlab/Octave Compatibility toolbox >> Matlab/Octave Compatibility toolbox > moc_randi

moc_randi

Return random integers in a given range

Calling Sequence

ri = moc_randi(imax)
ri = moc_randi(imax,n)
ri = moc_randi(imax,m,n,...)
ri = moc_randi([imin,imax],...)

Description

Additional arguments determine the shape of the return matrix. When no arguments are specified a single random integer is returned. If one argument n is specified then a square matrix (n x n) is returned. Two or more arguments will return a multi-dimensional matrix (m x n x ...).

The integer range may optionally be described by a two element matrix with a lower and upper bound in which case the returned integers will be on the interval [imin, imax].

Examples

// The following example returns 150 integers in the range 1-10.
ri = randi (10, 150, 1)

Authors


Report an issue
<< moc_prepad Matlab/Octave Compatibility toolbox moc_range >>