fixing of random number

조회 수: 2 (최근 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 CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by