Borrar filtros
Borrar filtros

Random number within a decimal range

4 visualizaciones (últimos 30 días)
Akif
Akif el 14 de Sept. de 2014
Comentada: Image Analyst el 14 de Sept. de 2014
How do I create a random number within the range 0.95 to 0.99? Any help is appreciated. Thanks in advance.

Respuesta aceptada

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh el 14 de Sept. de 2014
Editada: Salaheddin Hosseinzadeh el 14 de Sept. de 2014
Hi Akif,
This is exactly a copy paste from MATLAB's help, so for further info type
doc rand
Your solution
r = a + (b-a).*rand(100,1);
Be aware, rand is generates evenly distributed random randi is the same but integer, But randn generates normally distributed random (gaussian distribution)
Good Luck!
  2 comentarios
Akif
Akif el 14 de Sept. de 2014
Thanks
Image Analyst
Image Analyst el 14 de Sept. de 2014
And there's also a randi() that generates integers, though they're actually of class double, not an integer class, though they are rounded (no fraction).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by