I need to store up the different random for each realisation.
How do I set a seed to generate different random initial numbers and storing them
64 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Samson
am 2 Jul. 2020
Kommentiert: Samson
am 9 Jul. 2020
for kk = 1 : Iter
xD = rand(N,1)*2*pi; % Init Cond. Driver
end
3 Kommentare
Wiley Mosley
am 3 Jul. 2020
I think you are wanting a random repeatable setup.
I think the best way to set that up is to review:
Essentially you need to set a random repeatable seed so that you can reinitialize and run with the same random values for refining your code.
rng(1,'twister');
Akzeptierte Antwort
Weitere Antworten (1)
Wiley Mosley
am 3 Jul. 2020
Bearbeitet: Wiley Mosley
am 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.
9 Kommentare
Siehe auch
Kategorien
Mehr zu Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!