How to store value of rand() function in a file?
5 次查看(过去 30 天)
显示 更早的评论
I want to store the value of rand()(this function generate a number of value randomly) function in a file. Can anyone help please??
0 个评论
采纳的回答
Amit
2015-1-7
You can use fprintf - very nicely explained here with examples - http://www.mathworks.com/help/matlab/ref/fprintf.html
0 个评论
更多回答(2 个)
Chad Greene
2015-1-7
x = rand(5,1);
save example.mat 'x'
is simple and can be easily recalled with
load example
Alternatively, you may look into controlling random number generation with rng. By controlling the seed number you can consistently get the same "random" numbers every time you call rand.
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!