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.
The randn function gives arrays of real floating-point numbers that are made from a standard normal distribution. For example,
r3 = randn(1000,1);
r3 written above is a 1000-by-1 column vector containing numbers drawn from a standard normal distribution. Histogram of r3 comes like a roughly normal distribution whose mean is 0 and standard deviation is 1.
The randperm function can be used to create arrays of random integer values that have no repeated values. For example,
r4 = randperm(15,5);
r4 written above is a 1-by-5 array containing randomly selected integer values on the closed interval, [1, 15]. Unlike randi, which can give an array containing repeated values, the array returned by randperm has no repeated values.
Successive calls to any of above functions return different results. This behavior is helpful for creating several different arrays of random values.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.