%% Control Random Number Generation
% Save the current state of the random number generator and create a 1-by-5 vector of random integers.

s = rng;
r = randi(10,1,5)

%
% Restore the state of the random number generator to s, and then create a new 1-by-5 vector of random integers. The values are the same as before.

rng(s);
r1 = randi(10,1,5)

% Always use the rng function (rather than the rand or randn functions) to specify the settings of the random number generator. For more information, see Replace Discouraged Syntaxes of rand and randn.
% Copyright 2012 The MathWorks, Inc.