简体   繁体   中英

how to achieve RandStream.getDefaultStream in matlab2014a

I am trying to reproduce some random data generation. I was given some old matlab code.

defaultStream = RandStream.getDefaultStream;
savedState = defaultStream.State;
s = RandStream.create('mt19937ar','seed',seed);
RandStream.setDefaultStream(s);

After this code block, randperm was called in a loop.

Matlab 2014a do not have getDefaultStream for RandStream anymore. Is there any 2014a equivalence to the code above? I would like to be able to generate the same data as was done before. Thanks!

Those were renamed RandStream.getGlobalStream and RandStream.setGlobalStream .

Also now there is rng which is easier to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM