Generate random's number?

1 visualizzazione (ultimi 30 giorni)
Edoardo
Edoardo il 31 Ott 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

Risposta accettata

Matt J
Matt J il 31 Ott 2012
out=stream(randi(length(stream)));

Più risposte (1)

José-Luis
José-Luis il 31 Ott 2012
nVals = numel(your_stream);
your_val = your_stream(randperm(nVals,1));

Categorie

Scopri di più su Random Number Generation in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by