Generate random decimal value

How to generate random decimal value between 1.00 to 2.00?

 Accepted Answer

r=rand+1
r = 1.5233

4 Comments

Thank you so much. How about 50 random decimal values between 1.00 to 93.00?
The rand function creates random numbers from 0 to 1. See the documentation for more on specifying how many random numbers to create.
For your range, first create random numbers from 0-92 by multiplying the result by 92, then get it to go from 1-93 by adding 1.
r=rand(1,50)*92+1
r = 1×50
61.4748 9.3132 7.0734 80.1252 85.7785 54.4886 77.8041 22.8412 7.9122 36.5785 57.5735 9.9305 4.6449 38.0174 65.9258 76.0907 27.8438 55.9229 15.8530 1.9715 23.0542 4.4628 81.8775 27.8905 18.6223 74.1600 7.5745 3.2764 82.6740 54.1398
Thank you. Is it possible to create a left skewed distribution from the distribution above? I can't seem to find any resources on this.
rand creates a uniform distribution. You might look into the pearsrnd function, as that lets you define your distribution by setting the mean, standard deviation, skewness and kurtosis.

Sign in to comment.

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!