rng Control the random number generator used by RAND, RANDI, and RANDN.
rng(SD) seeds the random number generator using the non-negative integer SD so that RAND, RANDI, and RANDN produce a predictable sequence of numbers.
如:
% Get generator settings.
s = rng;
% Call rand.
x = rand(2,3);
% Restore previous generator
% settings.
rng(s);
% Call rand again and
% get the same results.
y = rand(2,3)
得到的x与y是完全相同的(因为y与x是在同一个 random number generator里);再如:<