本文介绍了matlabpool的替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用其他人的代码,其中包含以下行:

I am trying to use someone else's code and there is this line in it:

if (m<100) || (matlabpool('size')==0)

我正在使用MATLAB R2016a,因此此命令失败.新版本中的matlabpool('size')等效项是什么?

I am using MATLAB R2016a, so this command fails. What is the equivalent of matlabpool('size') in the new version?

我知道matlabpoolparpool代替.但是matlabpool('size')具体做什么?它实际上并没有创建并行工作器.

I know that matlabpool is replaced by parpool. But what does matlabpool('size') do specifically? It doesn't actually create the parallel workers.

推荐答案

按照更改日志:

matlabpool('size')完全按照您的期望进行操作:它为您提供了当前池的大小,即分配给它的工作人员的数量. gcp ( GetCurrentPool )可以为您完成此操作.其文档的第一个示例:

matlabpool('size') does exactly what you'd expect it to do: it gives you the size of the current pool, i.e. the amount of workers assigned to it. gcp (GetCurrentPool) does this for you. Its documentation's first example:

p = gcp('nocreate'); % If no pool, do not create new one.
if isempty(p)
    poolsize = 0;
else
    poolsize = p.NumWorkers
end

这篇关于matlabpool的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 00:05