fixing of random number

3 ビュー (過去 30 日間)
chan
chan 2021 年 10 月 23 日
コメント済み: chan 2021 年 10 月 23 日
I know how to fixed a random number for Y .when i run the program multiple times i want the random value generated for Y is same for all time but i dnt want to fixed the "node " random number . How not to fixed the "node " random number? Could someone plz give me some suggestion
rng(1)
Y=randi(10);
node=randi(20);

採用された回答

David Goodmanson
David Goodmanson 2021 年 10 月 23 日
編集済み: David Goodmanson 2021 年 10 月 23 日
Hi Irani,
If I understand your question correctly,
rng(1)
Y = randi(10)
rng('shuffle')
node = randi(20)
gives the same value for Y but different values for node each time this script is run.
  1 件のコメント
chan
chan 2021 年 10 月 23 日
thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by