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

 採用された回答

Matt J
Matt J 2012 年 10 月 31 日

1 投票

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

1 件のコメント

Edoardo
Edoardo 2012 年 10 月 31 日
Thanks you very much :)

サインインしてコメントする。

その他の回答 (1 件)

José-Luis
José-Luis 2012 年 10 月 31 日

1 投票

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

1 件のコメント

Edoardo
Edoardo 2012 年 10 月 31 日
Thanks you very much :)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

製品

質問済み:

2012 年 10 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by