I am looking to generate random numbers between a certain set of decimal numbers (for eg: 0.3 to 0.4). I tried using rand command but if anyone has a workaround?

 Respuesta aceptada

Voss
Voss el 31 de Mayo de 2022
rand gives you number(s) between 0 and 1, so with appropriate scaling and offsetting, you can use it to get number(s) from any given range:
data = 0.3 + 0.1*rand(1,100) % 100 numbers between 0.3 and 0.4
data = 1×100
0.3596 0.3187 0.3503 0.3990 0.3179 0.3482 0.3384 0.3025 0.3906 0.3738 0.3543 0.3069 0.3705 0.3117 0.3616 0.3272 0.3565 0.3828 0.3806 0.3173 0.3632 0.3188 0.3767 0.3447 0.3255 0.3521 0.3875 0.3934 0.3428 0.3297
plot(data)

Más respuestas (0)

Categorías

Productos

Versión

R2021a

Preguntada:

el 31 de Mayo de 2022

Respondida:

el 31 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by