| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
r = randi(s,imax,n)
randi(s,imax,m,n)
randi(s,imax,[m,n])
randi(s,imax,m,n,p,...)
randi(s,imax,[m,n,p,...])
randi(s,imax)
randi(s,imax,size(A))
r = randi(s,[imin,imax],...)
r = randi(..., classname)
r = randi(s,imax,n) returns an n-by-n matrix containing pseudorandom integer values drawn from the discrete uniform distribution on 1:imax. randi draws those values from the random stream s. randi(s,imax,m,n) or randi(s,imax,[m,n]) returns an m-by-n matrix. randi(s,imax,m,n,p,...) or randi(s,imax,[m,n,p,...]) returns an m-by-n-by-p-by-... array. randi(s,imax) returns a scalar. randi(s,imax,size(A)) returns an array the same size as A.
r = randi(s,[imin,imax],...) returns an array containing integer values drawn from the discrete uniform distribution on imin:imax.
r = randi(..., classname) returns an array of integer values of class classname. classname does not support 64-bit integers.
Note The size inputs m, n, p, ... should be nonnegative integers. Negative integers are treated as 0. |
The sequence of numbers produced by randi is determined by the internal state of the random stream s. randi uses one uniform value from s to generate each integer value. Resetting s to the same fixed state allows computations to be repeated. Setting the stream to different states leads to unique computations, however, it does not improve any statistical properties.
rand, @RandStream, rand (RandStream), randn (RandStream), randperm (RandStream)
![]() | randi | randn | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |