How to make elements in an array permanant

1 Ansicht (letzte 30 Tage)
Qilin
Qilin am 27 Mär. 2013
I'm creating function that has a random array using randperm. Is there a way to fix the order of the elements in the array even when I run it several times? Every time I use the function, a new array will be produced. I want the function to be so that the randperm will only run once no matter how many times I click 'run'. Thanks

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 27 Mär. 2013
You can save your array in a mat file
  1 Kommentar
Azzi Abdelmalek
Azzi Abdelmalek am 27 Mär. 2013
Bearbeitet: Azzi Abdelmalek am 27 Mär. 2013
Or
stream = RandStream('twister','Seed',0); % 'twister' is a generator
randperm(stream,5)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

James Tursa
James Tursa am 27 Mär. 2013
You could fix the seed used every time so you get the same stream of random numbers with each trial. See the rng function:

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by