How to store value of rand() function in a file?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Twinkle katiyar
le 7 Jan 2015
Réponse apportée : Sean de Wolski
le 7 Jan 2015
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 commentaires
Réponse acceptée
Amit
le 7 Jan 2015
You can use fprintf - very nicely explained here with examples - http://www.mathworks.com/help/matlab/ref/fprintf.html
0 commentaires
Plus de réponses (2)
Chad Greene
le 7 Jan 2015
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 commentaires
Sean de Wolski
le 7 Jan 2015
Or:
matlab.io.saveVariablesToScript
If you want a runnable script.
0 commentaires
Voir également
Catégories
En savoir plus sur Random Number Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!