Random Number Generation
Random Number Generation
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
There are four basic fundamental random number functions available in MATLAB: rand, randi, randn, and randperm.
The rand function returns real numbers between 0 and 1 that are drawn from a uniform distribution in MATLAB. For example,
r1 = rand(1000,1);
r1 is a 1000-by-1 column vector containing real floating-point numbers drawn from a uniform distribution. All the values in r1 are in the open interval (0, 1). Histogram of these values is show roughly flat nature, which indicates a fairly uniform sampling of numbers.
The randi function gives back double integer values drawn from a discrete uniform distribution.
r2 = randi(10,1000,1);
r2 is a 1000-by-1 column vector containing integer values drawn from a discrete uniform distribution whose range is 1,2,…,10. A histogram of these values is also turnout to be roughly flat in nature, which indicates a fairly uniform sampling of integers between 1 and 10.
SEE COMPLETE ANSWER CLICK THE LINK