Borrar filtros
Borrar filtros

Generate random's number?

6 visualizaciones (últimos 30 días)
Edoardo
Edoardo el 31 de Oct. de 2012
Hi;
How can I create a random's stream that generated only one number?
Exemple;
I have this strema 0,40,80,110,150,180.... I would like that to have a variable rappresented by one number choosed randomly from the stream.
Thanks Edoardo

Respuesta aceptada

Matt J
Matt J el 31 de Oct. de 2012
out=stream(randi(length(stream)));
  1 comentario
Edoardo
Edoardo el 31 de Oct. de 2012
Thanks you very much :)

Iniciar sesión para comentar.

Más respuestas (1)

José-Luis
José-Luis el 31 de Oct. de 2012
nVals = numel(your_stream);
your_val = your_stream(randperm(nVals,1));
  1 comentario
Edoardo
Edoardo el 31 de Oct. de 2012
Thanks you very much :)

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots 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