Generate random's number?

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

1 voto

out=stream(randi(length(stream)));

Más respuestas (1)

José-Luis
José-Luis el 31 de Oct. de 2012

1 voto

nVals = numel(your_stream);
your_val = your_stream(randperm(nVals,1));

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 31 de Oct. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by