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!