Decimal random number generator
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I want to generate a random number generator 0 to 1 should include values with ten decimal points.As default i get only 4 decimals.
Thanking You,
Sita
1 commentaire
Jan
le 28 Jan 2013
Where did all the comments go? Did you delete them? If so, why? Without them our answers looks a little bit unmotivated, not to say lunatic. Therefore removing important data from a thread is not wanted.
Réponses (3)
Sachin Ganjare
le 25 Jan 2013
Modifié(e) : Jan
le 25 Jan 2013
out = rand(1, 1);
decimal_out = floor(out * 100000000);
decimal_out = decimal_out\100000000;
Jan
le 25 Jan 2013
What about using rand() directly, because it satisfies: at least 8 decimal digits already?
1 commentaire
Jan
le 25 Jan 2013
Modifié(e) : Jan
le 25 Jan 2013
The limitation to 4 digits appears in the command line only, see: help format.
format long g
disp(rand(2,2))
Although I assume your code is just an abbreviated example, I recommend not to use "min" and "max" as names of variables, because this shadows frequently used Matlab commands.
However, I still do not understand your question. What does "fixing the number of decimal points" mean? RAND does reply values like 0.00000000001 also, so what is the problem.
Evgeny Pr
le 25 Jan 2013
Modifié(e) : Evgeny Pr
le 25 Jan 2013
Do you have the distribution law for pseudo-random numbers for your problem? You can use RAND function for generate uniformly distributed numbers and define its non-linear (or linear) transformation function:
numbers = rand(10);
transformedNumbers = transform_function(numbers);
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!