I am trying to generate random numbers from 0.1 - 0.7.
My current code is close to what I need, but is giving me numbers lower than 0.1:
frameDur1 = roundn((((7)*rand(1))/10), -2);
If you have suggestions on another/easier function I could use, that would be appreciated as well.
Thanks in advance!
*Don't believe this question is a duplicate, but thanks to Ali Rokni for the answer.
rand
generate uniformly distributed random numbers between (0,1). Your range size is
0.7 - 0.1 = 0.6 % max - min
First you should change the range to (0, 0.6). And then you add the minimum for changing the offset.
Therefore ultimately you have
0.1 + (0.7 - 0.1) * rand
Generally speaking assuming your desired range is (min, max)
min + (max - min) * rand
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments