what is Rand() function in matlab simulation software?

Type: >> help rand
On the window you will get the message:-

RAND Uniformly distributed pseudorandom numbers.
R = RAND(N) returns an N-by-N matrix containing pseudorandom values drawn
from the standard uniform distribution on the open interval(0,1). RAND(M,N)
or RAND([M,N]) returns an M-by-N matrix. RAND(M,N,P,…) or
RAND([M,N,P,…]) returns an M-by-N-by-P-by-… array. RAND returns a
scalar. RAND(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 = RAND(…, ‘double’) or R = RAND(…, ‘single’) returns an array of
uniform values of the specified class.

Compatibility Note: In versions of MATLAB prior to 7.7, you controlled
the internal state of the random number stream used by RAND by calling
RAND directly with the ‘seed’, ‘state’, or ‘twister’ keywords. That
syntax is still supported for backwards compatibility, but is deprecated.
Beginning in MATLAB 7.7, use the default stream as described in

The sequence of numbers produced by RAND is determined by the internal
state of the uniform pseudorandom number generator that underlies RAND,
RANDI, and RANDN. Control that default random number stream using its
properties and methods. See RANDSTREAM for details about the default

Resetting the default stream 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.
Since MATLAB uses the same state each time it starts up, RAND, RANDN, and
RANDI will generate the same sequence of numbers in each session unless
the state is changed.


Generate values from the uniform distribution on the interval [a, b].
r = a + (b-a).*rand(100,1);

Generate integer values from the uniform distribution on the set 1:n.
r = randi(100,1);

Save the current state of the default stream, generate 5 values,
restore the state, and repeat the sequence.
defaultStream = RandStream.getDefaultStream;
savedState = defaultStream.State;
u1 = rand(1,5)
defaultStream.State = savedState;
u2 = rand(1,5) % contains exactly the same values as u1

Replace the default stream with a stream whose seed is based on CLOCK, so
RAND will return different values in different MATLAB sessions. NOTE: It
is usually not desirable to do this more than once per MATLAB session.


See more:-

ইঞ্জিনিয়ার ছাত্র ছাত্রীদের প্রাক্টিকাল কাজ করার জন্য সকল ধরনের ইঞ্জিনিয়ারিং প্রোডাক্ট স্বল্প মূল্যে ঘরে বসে পেতে এখনি ভিজিট করুন উপকরণ ডট কমে। ইঞ্জিনিয়ার ছাত্র ছাত্রীরা একবার হলেও এই ওয়েবসাইটি দেখে আসুন। এখানে ক্লিক করুন www.upokoron.com

Write Your Comments


Leave a Reply