how to generate and precise double value?

2 visualizaciones (últimos 30 días)
Mira le
Mira le el 27 de Oct. de 2020
Comentada: Mira le el 27 de Oct. de 2020
Hello
I want to ask you How I can generate probability values randomly between 0 and 1, but 1 and 0 can include as probability value
for example
I have a vector of values X=[12 5 10 50 22]
each value of X must have a probability where 0<=p>=1
when I obtain probability like 0.98555 I want just pick 0.9
How I can do that.?
Please help me!

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Oct. de 2020
randi([0 10], size(x))./10
  1 comentario
Mira le
Mira le el 27 de Oct. de 2020
Why do you choose 10?
I try it and the result is ;
0.9000 0.5000 0.5000 0.3000 0.7000
could we remove these zeros after this comma?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by