Hi, I want to generate 12 different sets of random variables whose elements be fixed in every run. Because these data are inputs of other codes and must be fixed. How can I do this.
16 views (last 30 days)
Show older comments
matlab programing
2 Comments
Walter Roberson
on 12 Jan 2016
Do you mean that the elements in one set must be a permutation of the elements in another set?
Answers (1)
Image Analyst
on 12 Jan 2016
Use rng() to get the same sets of numbers each time:
% Initialize random number generator with a constant seed to start.
rng(1); % Pick any seed number you want
% The following 12 sets will always be the same in every run.
set1 = rand(1,5)
set2 = rand(1,5)
set3 = rand(1,5)
set4 = rand(1,5)
set5 = rand(1,5)
set6 = rand(1,5)
set7 = rand(1,5)
set8 = rand(1,5)
set9 = rand(1,5)
set10 = rand(1,5)
set11 = rand(1,5)
set12 = rand(1,5)
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!