%% Save and Restore the Generator Settings
%% Section 1
% First, initialize the random number generator to make the results in this example repeatable.

rng(1,'twister');

% Create an array of random integer values between 1 and 10.

A = randi(10,3,3)

% The first call to randi changed the state of the generator. Save the generator settings after the first call to randi in a structure s.

s = rng;

% Create another array of random integer values between 1 and 10.

A = randi(10,3,3)

% Now, return the generator to the previous state stored in s and reproduce the second array A.

rng(s);
A = randi(10,3,3)

%
% Copyright 2012 The MathWorks, Inc.