MATLAB: Random numbers seed setting

MATLABseed

Hi,
I am using randn('seed', 1) at the beginning of my code for a simulation with 1000 replications. This is to make sure that if I rerun the simulation I'll get same results every time. But I am getting slightly different results in different runs. Can anyone help? I am using Matlab 2012a.

Best Answer

Use
a=rng;
out=randn
rng(a)
out=randn
Related Question