You are on page 1of 5


help rand
<strong>rand</strong> Uniformly distributed pseudorandom numbers.
R = <strong>rand</strong>(N) returns an N-by-N matrix containing pseudorando
m values drawn
from the standard uniform distribution on the open interval(0,1). <strong>r
or <strong>rand</strong>([M,N]) returns an M-by-N matrix. <strong>rand</str
ong>(M,N,P,...) or
<strong>rand</strong>([M,N,P,...]) returns an M-by-N-by-P-by-... array. <st
rong>rand</strong> returns a
scalar. <strong>rand</strong>(SIZE(A)) returns an array the same size as A.
Note: The size inputs M, N, P, ... should be nonnegative integers.
Negative integers are treated as 0.
R = <strong>rand</strong>(..., 'double') or R = <strong>rand</strong>(..., '
single') returns an array of
uniform values of the specified class.
The sequence of numbers produced by <strong>rand</strong> is determined by t
he settings of
the uniform random number generator that underlies <strong>rand</strong>, RA
Control that shared random number generator using RNG.
Example 1: Generate values from the uniform distribution on the
interval [a, b].
r = a + (b-a).*rand(100,1);
Example 2: Use the RANDI function, instead of <strong>rand</strong>, to g
integer values from the uniform distribution on the set 1:100.
r = randi(100,1,5);
Example 3: Reset the random number generator used by <strong>rand</strong
>, RANDI, and
RANDN to its default startup settings, so that <strong>rand</strong> prod
uces the same
random numbers as if you restarted MATLAB.
Example 4: Save the settings for the random number generator used by
<strong>rand</strong>, RANDI, and RANDN, generate 5 values from <strong>r
and</strong>, restore the
settings, and repeat those values.
s = rng
u1 = rand(1,5)
u2 = rand(1,5) % contains exactly the same values as u1
Example 5: Reinitialize the random number generator used by <strong>rand<
RANDI, and RANDN with a seed based on the current time. <strong>rand</st
rong> will
return different values each time you do this. NOTE: It is usually

not necessary to do this more than once per MATLAB session.

See <a href="matlab:helpview([docroot '\techdoc\math\'],'update_rand
om_number_generator')">Updating Your Random Number Generator Syntax</a> to use R
NG to replace
<strong>rand</strong> with the 'seed', 'state', or 'twister' inputs.
See also <a href="matlab:help randi">randi</a>, <a href="matlab:help randn">
randn</a>, <a href="matlab:help rng">rng</a>, <a href="matlab:help RandStream">R
andStream</a>, <a href="matlab:help RandStream/rand">RandStream/rand</a>,
<a href="matlab:help sprand">sprand</a>, <a href="matlab:help spran
dn">sprandn</a>, <a href="matlab:help randperm">randperm</a>.
Overloaded methods:
<a href="matlab:help
<a href="matlab:help
<a href="matlab:help
<a href="matlab:help
<a href="matlab:help
<a href="matlab:help


Reference page in Help browser

<a href="matlab:doc rand">doc rand</a>
lookfor format
<a href="matlab:help MException">MException</a>
- Capture er
ror information.
<a href="matlab:help BioMap">BioMap</a>
- class represen
ting a collection of sequences and their alignment information.
<a href="matlab:help biograph">biograph</a>
- creates a bi
oinformatics graph object
<a href="matlab:help geneont">geneont</a>
- creates a Gen
e Ontology object from an 'OBO' formatted file.
<a href="matlab:help zpk">zpk</a>
- Constructs zero-p
ole-gain model or converts to zero-pole-gain format.
<a href="matlab:help mbcuser">mbcuser</a>
- Create an obj
ect that contains user information
<a href="matlab:help cgcaloutput">cgcaloutput</a>
- Object fo
r exporting calibration information
<a href="matlab:help mbcboxcox">mbcboxcox</a>
- Box-Cox tra
<a href="matlab:help mbcmodeloutput">mbcmodeloutput</a>
- model
output signal information and transforms
<a href="matlab:help TargetsComms_VectorApplicationChannel">TargetsComms_VectorA
pplicationChannel</a> - class representing information about vector application
<a href="matlab:help DataTypeHandler_BuiltinDataType">DataTypeHandler_BuiltinDat
aType</a> - class to hold information about a primitive type
<a href="matlab:help DataTypeHandler_DataType">DataTypeHandler_DataType</a>
- class to hold information about a data type
<a href="matlab:help TargetsComms_Machine">TargetsComms_Machine</a>
class to hold information about a machine
<a href="matlab:help getFileCustomData">getFileCustomData</a>
- ret
urns the custom data in xml format for the given
<a href="matlab:help ssdisp">ssdisp</a>
- Display text f
rom the Slide Show format.
<a href="matlab:help sspause">sspause</a>
- Pause functio
n for the Slide Show format.

<a href="matlab:help textscanDemo">textscanDemo</a>

- Reading
Arbitrary Format Text Files with TEXTSCAN
<a href="matlab:help texlabel">texlabel</a>
- Produces the
TeX format from a character string.
<a href="matlab:help viewmtx">viewmtx</a>
- View transfor
mation matrix.
<a href="matlab:help hgdisp">hgdisp</a>
- displays HG ha
ndle object information
<a href="matlab:help im2frame">im2frame</a>
- Convert inde
xed image into movie format.
<a href="matlab:help version">version</a>
- Version infor
mation for MATLAB and libraries.
<a href="matlab:help convertSpreadsheetDates">convertSpreadsheetDates</a>
- Convert cells in a spreadsheet to MATLAB datenum format
<a href="matlab:help profsave">profsave</a>
- Save profile
report in HTML format
<a href="matlab:help functions">functions</a>
- Return info
rmation about a function handle.
<a href="matlab:help flintmax">flintmax</a>
- Largest cons
ecutive integer in floating point format.
<a href="matlab:help format">format</a>
- Set output for
<a href="matlab:help libfunctions">libfunctions</a>
- Return i
nformation on functions in a shared library.
<a href="matlab:help memory">memory</a>
- Memory informa
<a href="matlab:help saveas">saveas</a>
- Save Figure or
Simulink block diagram in desired output format
<a href="matlab:help syntax">syntax</a>
- You can enter
MATLAB commands using either a FUNCTION format or a
<a href="matlab:help ver">ver</a>
- MATLAB, Simulink
and toolbox version information.
<a href="matlab:help demowin">demowin</a>
- Display demo
information in the Help window
<a href="matlab:help displayEndOfDemoMessage">displayEndOfDemoMessage</a>
- Explain how to get more information about a demo.
<a href="matlab:help info">info</a>
- Information abou
t MathWorks.
<a href="matlab:help dataread">dataread</a>
- Read formatt
ed data from string or file.
<a href="matlab:help fprintf">fprintf</a>
- Write formatt
ed data to text file.
<a href="matlab:help textread">textread</a>
- Read formatt
ed data from text file.
<a href="matlab:help textscan">textscan</a>
- Read formatt
ed data from text file or string.
<a href="matlab:help ParallelException">ParallelException</a>
- Cap
ture error information from errors thrown in user code inside a parallel languag
e construct.
<a href="matlab:help lasterror">lasterror</a>
- Last error
message and related information.
<a href="matlab:help qhull">qhull</a>
- Copyright infor
mation for Qhull.
<a href="matlab:help spconvert">spconvert</a>
- Import from
sparse matrix external format.
<a href="matlab:help regexptranslate">regexptranslate</a>
- Regul
ar expression related string transformations
<a href="matlab:help sprintf">sprintf</a>
- Write formatt
ed data to string.
<a href="matlab:help sscanf">sscanf</a>
- Read string un

der format control.

<a href="matlab:help strread">strread</a>
- Read formatte
d data from string.
<a href="matlab:help datetick">datetick</a>
- Date formatt
ed tick labels.
<a href="matlab:help transformLogicBlockDefaultDataType">transformLogicBlockDefa
ultDataType</a> - Transformation Function for old Logic blocks:
<a href="matlab:help cminfo">cminfo</a>
- Information ab
out configuration managers defined in this file.
<a href="matlab:help fcncallobj_close_cb">fcncallobj_close_cb</a>
- D
elete dialog related cache information
<a href="matlab:help getHardwareConfigs">getHardwareConfigs</a>
- get the detailed information of model hardware configuration.
<a href="matlab:help libinfo">libinfo</a>
- library infor
<a href="matlab:help slcm">slcm</a>
- Simulink Configu
ration Information Block.
<a href="matlab:help viewlinkdata">viewlinkdata</a>
- controls
and manages the display of LinkData information
<a href="matlab:help sldemo_slproject_convert_to_SLX">sldemo_slproject_convert_t
o_SLX</a> - Converting from MDL to SLX Model File Format in a Simulink Project
<a href="matlab:help sldemo_state_logging_script">sldemo_state_logging_script</a
- Logging States in Structure Format
<a href="matlab:help sldemo_eml_galaxy_script">sldemo_eml_galaxy_script</a>
- Spiral Galaxy Formation Simulation Using MATLAB(R) Function Blocks
<a href="matlab:help astFormatContourLines">astFormatContourLines</a>
: Helper function to format major contour lines' color
<a href="matlab:help astPlotWMMContours">astPlotWMMContours</a>
- as
tFormatContourLines: Helper function to create the contour maps for the
<a href="matlab:help audiodevinfo">audiodevinfo</a>
- Audio de
vice information.
<a href="matlab:help audioinfo">audioinfo</a>
- Information
about an audio file.
<a href="matlab:help aviinfo">aviinfo</a>
- Information a
bout AVI file.
<a href="matlab:help mmcompinfo">mmcompinfo</a>
- Multimedia
compressor information.
<a href="matlab:help mmfileinfo">mmfileinfo</a>
- Informatio
n about a multimedia file.
<a href="matlab:help baminfo">baminfo</a>
- Information a
bout BAM format file.
lookfor rand
<a href="matlab:help RandStream">RandStream</a>
- Random num
ber stream.
<a href="matlab:help BioIndexedFile">BioIndexedFile</a>
- class
allows random read access to text files using an index file.
<a href="matlab:help qrandset">qrandset</a>
- Quasi-random
point set class.
<a href="matlab:help qrandstate">qrandstate</a>
- This undoc
umented class may be removed in a future release.
<a href="matlab:help qrandstream">qrandstream</a>
- Create a
quasi-random stream.
<a href="matlab:help rngdemo">rngdemo</a>
- Controlling R
andom Number Generation
<a href="matlab:help rand">rand</a>
- Uniformly distri
buted pseudorandom numbers.
<a href="matlab:help randi">randi</a>
- Pseudorandom in
tegers from a uniform discrete distribution.
<a href="matlab:help randn">randn</a>
- Normally distri
buted pseudorandom numbers.

<a href="matlab:help randperm">randperm</a>

- Random permu
<a href="matlab:help rng">rng</a>
- Control the rando
m number generator used by RAND, RANDI, and RANDN.
<a href="matlab:help rjr">rjr</a>
- Random Jacobi rot
<a href="matlab:help sprand">sprand</a>
- Sparse uniform
ly distributed random matrix.
<a href="matlab:help sprandn">sprandn</a>
- Sparse normal
ly distributed random matrix.
<a href="matlab:help sprandsym">sprandsym</a>
- Sparse rand
om symmetric matrix.
<a href="matlab:help flowprandtlmeyer">flowprandtlmeyer</a>
- Calc
ulate Prandtl-Meyer functions for expansion waves
<a href="matlab:help hmmprofgenerate">hmmprofgenerate</a>
- gener
ates a random sequence using a profile HMM.
<a href="matlab:help randseq">randseq</a>
- generates a r
andom sequence.
<a href="matlab:help seqcomplement">seqcomplement</a>
- returns
the complementary strand of a DNA sequence.
<a href="matlab:help seqrcomplement">seqrcomplement</a>
- return
s the reverse complementary strand of a DNA sequence.
<a href="matlab:help seqreverse">seqreverse</a>
- returns th
e reverse strand of a DNA or RNA sequence.
<a href="matlab:help randfeatures">randfeatures</a>
- generate
s a randomized subset of features
<a href="matlab:help acghhmmsample">acghhmmsample</a>
- The ran
dom sampling function for ACGHHMMDEMO
<a href="matlab:help legacychannelsim">legacychannelsim</a>
- Togg
les random number generation mode for channel objects
<a href="matlab:help randdeintrlv">randdeintrlv</a>
- Restore
ordering of symbols using a random permutation.
<a href="matlab:help randerr">randerr</a>
- Generate bit
error patterns.
<a href="matlab:help randintrlv">randintrlv</a>
- Reorder sy
mbols using a random permutation.
<a href="matlab:help randseed">randseed</a>
- Generate pri
me numbers for use as random number seeds.
<a href="matlab:help randsrc">randsrc</a>
- Generate rand
om matrix using prescribed alphabet.
<a href="matlab:help commblkrandintsrc2">commblkrandintsrc2</a>
- Ma
sk dynamic dialog function for Random Integer Generator block
<a href="matlab:help toccommsources">toccommsources</a>
- Random
data, PN, orthogonal codes, random noise
x =
{Undefined function or variable 'untitled10'.