MATLAB: Do I get the same numbers in “randn” function

MATLABrandom number generator

Every time I open MATLAB the first time I get the same values when I use randn function. This happens only after I first open MATLAB and not when the program is already open and I keep coming back for calculations.

Best Answer

You get the same numbers because there's a default seed (0) for the random number generator but you can change it like this:
RandStream.setDefaultStream(RandStream('mt19937ar','seed',sum(100*clock)))
If you want to see what changed do RandStream.getDefaultStream before and after changing the seed.