设置使用的CPU核心数目
myCluster = parcluster('local');
myCluster.NumWorkers = 4; % 'Modified' property now TRUE
saveProfile(myCluster); % 'local' profile now updated,
% 'Modified' property now FALSE
if isempty(gcp)
distcomp.feature('LocalUseMpiexec', false);
c = parcluster;
pool = parpool(c.NumWorkers);
end
设置进程池的数量
CoreNum=6; %设定机器CPU核心数量
if isempty(gcp('nocreate')) %如果并行未开启
parpool(CoreNum);
end