Generate random's number?

1 vue (au cours des 30 derniers jours)
Edoardo
Edoardo le 31 Oct 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

Réponse acceptée

Matt J
Matt J le 31 Oct 2012
out=stream(randi(length(stream)));
  1 commentaire
Edoardo
Edoardo le 31 Oct 2012
Thanks you very much :)

Connectez-vous pour commenter.

Plus de réponses (1)

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Random Number Generation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by