Effacer les filtres
Effacer les filtres

Generating random numbers from a certain interval

1 vue (au cours des 30 derniers jours)
arwa
arwa le 17 Nov 2016
Commenté : arwa le 17 Nov 2016
Hi, I generated random numbers within the range 0.0 to 0.01 by this code x= 0.0 + (0.01-0.0).*rand() ,but some of generated random numbers x have unwanted value like "1.1902e-004". How can I solve and skip this value to obtain normal values?
Thanks in advance,

Réponse acceptée

Geoff Hayes
Geoff Hayes le 17 Nov 2016
area - 1.1902e-004 is an alternative format to writing 0.00011902 which is a valid number within your interval. Try calling
format long g
before running your code (to generate the random numbers) and you should see how the effect of this format.
  1 commentaire
arwa
arwa le 17 Nov 2016
well, i've tried. it's done
Many thanks for you...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by