Difference rand and randn command matlab

  • Thread starter Thread starter eltrinco
  • Start date Start date
  • Tags Tags
    Difference Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 24K views
eltrinco
Messages
6
Reaction score
0
i am confused between when to use rand and randn . can someone explain to me please?
 
Physics news on Phys.org
Both are pseudo-random number generators.
http://www.mathworks.com/help/matlab/random-number-generation.html

type "help rand" and "help randn" for a description.

Code:
rand()
Return a matrix with random elements uniformly distributed 
on the interval (0, 1).  The arguments are handled the same 
as the arguments for `eye'.

randn() 
Return a matrix with normally distributed pseudo-random 
elements having zero mean and variance one.  The arguments 
are handled the same as the arguments for `rand'.

You should be able to see the result by filling a vector with them and plotting.
 
  • Like
Likes   Reactions: 1 person