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 件のコメント
Sean de Wolski
2015 年 1 月 7 日
Or:
matlab.io.saveVariablesToScript
If you want a runnable script.
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!