my random changes its values during running my code
8 次查看(过去 30 天)
显示 更早的评论
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??
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!