my random changes its values during running my code

조회 수: 8 (최근 30일)
heba raouf
heba raouf 2021년 2월 24일
댓글: heba raouf 2021년 2월 26일
i working on my matlab code to generate data size with specific mean and value. so i used the following syntax:
mu=30;var=100;
ts=mu+sqrt(var)*randn(1,10);
but each time i run the code, the number inside ts vector changes and i need it to constant.
this problem affect the remaining steps of code and make size changes.
any solution to this problem??

채택된 답변

Hernia Baby
Hernia Baby 2021년 2월 24일
편집: Hernia Baby 2021년 2월 24일
You can generate random numbers that are repeatable with saving and restoring the generator setting.
rng(1,'twister');
mu=30;var=100;
ts=mu+sqrt(var)*randn(1,10);
ts
Detail:

추가 답변 (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