unifrnd

unifrnd(a,b) returns random numbers from the continuous uniform distribution on (a, b).
  • unifrnd(a,b) returns a random distribution generated from each elements of a and b. If one of them is a scalar, it will be expanded to the size of the other argument.
  • unifrnd(a,b,nr,nc) or unifrnd(a,b,[nr,nc]) returns a matrix with nr number of rows and nc number of colulmns.

Examples

>> rng(0) 

% for tractability

unifrnd(1,6)# 3.74407 >> rng(0) unifrnd(1:5,6)#

% b is expanded to the size of a

3.74407 4.37138 5.14557 5.68853 5.60276 >> rng(0) unifrnd(1:2,6:7)# 3.74407 4.96422
>> rng(0) 
unifrnd(1,5,2,1)# 

% generating 2x1 vector from the continuous uniform distribution on (1,5)

3.19525 3.37138

See also

rand | randi | randperm | rng