I need to perform few tests where I use randn pseudo random number generator. How can I set the seed on my own, so every time I run this test I will get the same results? (yeah, I know it’s a little bit weird, but that’s the problem).
I’ve found the RANDSTREAM object that has the seed property, but it’s read only. Is there any way to use it for seeding the generator?
The old way of doing it:
The new way:
Note that if you use the new way,
randandrandnshare the same stream so if you are calling both, you may find different numbers being generated compared to the old method (which has separate generators). The old method is still supported for this reason (and legacy code).See http://www.mathworks.com/help/techdoc/math/bsn94u0-1.html for more info.