%% Set and Restore Generator Settings
% Set the random number generator to the default seed (0) and algorithm (Mersenne Twister), then save the generator settings.

rng('default')
s = rng

% Create a 1-by-5 row vector of random values between 0 and 1.

x = rand(1,5)

% Change the generator seed and algorithm, and create a new random row vector.

rng(1,'philox')
xnew = rand(1,5)

% Now restore the original generator settings and create a random vector. The result matches the original row vector x created with the default generator.

rng(s)
xold = rand(1,5)

% Copyright 2019 The MathWorks, Inc.