Random Number Generator Matlab with Multiple CPUs

后端 未结 4 635
梦如初夏
梦如初夏 2020-12-18 13:57

I would like to write a matlab script which runs in parallel using multiple CPUS. The script should then print out a sequence of normally distributed random numbers. At the

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 14:05

    You can set the random seed to a different value for each iteration:

    matlabpool close force local
    clusterObj = parcluster;
    matlabpool(clusterObj);
    
    rng('shuffle');
    seeds = round(10000*abs(randn(10,1)));
    
    parfor K = 1:10
        rng(seeds(K))
        disp(randn)
    end 
    

提交回复
热议问题