Generate random's number?

1 Ansicht (letzte 30 Tage)
Edoardo
Edoardo am 31 Okt. 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

Akzeptierte Antwort

Matt J
Matt J am 31 Okt. 2012
out=stream(randi(length(stream)));
  1 Kommentar
Edoardo
Edoardo am 31 Okt. 2012
Thanks you very much :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

José-Luis
José-Luis am 31 Okt. 2012
nVals = numel(your_stream);
your_val = your_stream(randperm(nVals,1));
  1 Kommentar
Edoardo
Edoardo am 31 Okt. 2012
Thanks you very much :)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by