7 views (last 30 days)

for kk = 1 : Iter

xD = rand(N,1)*2*pi; % Init Cond. Driver

end

Wiley Mosley
on 3 Jul 2020

Edited: Wiley Mosley
on 3 Jul 2020

rng(1,'twister'); % init generator for random repeatable with seed 1

s = rng; % save generator settings as s

for kk = 1: Iter

xD = rand (N, 1) * 2 * pi; % Init Cond. Driver

end

disp(xD) %just to print out your xD values

rng(s) % Reset the generator

for kk = 1: Iter

xD = rand (N, 1) * 2 * pi; % Init Cond. Driver

end

disp(xD) %printing out the xD values again should show that they match

I believe somthing like this should help you.

Walter Roberson
on 8 Jul 2020

Iter = 100;

rstates = cell(Iter,1);

for kk = 1 : Iter

rstates{kk} = rng(); %record current rng

xD = rand(N,1)*2*pi; % Init Cond. Driver

[t_IF, t_FS, zVals] = changesN_TestChaosMain( N, G, alphaD, omegaD, xD, NumberWindows, WindowLength, dt);

lifetimes(kk) = t_FS - t_IF;

end

Later if you wwant to look at xD for iteration #17, then

rng(rstates{17});

xD = rand(N,1)*2*pi; % same random values used for iteration #17

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/558698-how-do-i-set-a-seed-to-generate-different-random-initial-numbers-and-storing-them#comment_922796

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/558698-how-do-i-set-a-seed-to-generate-different-random-initial-numbers-and-storing-them#comment_922796

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/558698-how-do-i-set-a-seed-to-generate-different-random-initial-numbers-and-storing-them#comment_922868

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/558698-how-do-i-set-a-seed-to-generate-different-random-initial-numbers-and-storing-them#comment_922868

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/558698-how-do-i-set-a-seed-to-generate-different-random-initial-numbers-and-storing-them#comment_923525

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/558698-how-do-i-set-a-seed-to-generate-different-random-initial-numbers-and-storing-them#comment_923525

Sign in to comment.