MATLAB: In Unix, not replaced variables

unix

Hello all, I am running Matlab jobs in the background on Unix server. For simple example, the ex.m file contains;
for i=1:10; a(i)=normrnd(1,1); end;
and I am running this file on Unix as seen below; matlab -nodesktop -nodisplay < ex.m >&file.out&
The problem is that if I repeat this job, I obtain the exactly same 'a' values. Although I removed all the result files and rerun the program, the 'a' variable didn't change at all.
I appreciate any answers. Thank you.

Best Answer

MATLAB starts with the same seed for the random number generator. To get different numbers, you need differently inilitializations. A secure method to get independent seeds is e.g. FEX: randi.org.