Borrar filtros
Borrar filtros

How do I generate a random number in an interval?

28 visualizaciones (últimos 30 días)
Jeroen
Jeroen el 22 de Abr. de 2013
Is there a standard function in Matlab that can generate a random rational number in a certain interval?
e.g. ...([1,2]) => 1.35
...([0,4)] => 2.64
...([-3.2, 5.9]) => -3.84

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 22 de Abr. de 2013
See Example 1 in:
  1 comentario
Jeroen
Jeroen el 22 de Abr. de 2013
I eventually used
a+(b-a)*rand(1,1)
to create a random number in the interval [a,b] and unless I've had a lot of luck until now, it works perfectly. This helped me aswell: http://www.mathworks.com/matlabcentral/answers/33121.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by