Undefined operator ':' for input arguments of type 'parallel.Pool'

2 次查看(过去 30 天)
These are the code:
% chunk the data up
numData = size(X,2) ;
numChunks = parpool('local', 2);
data = Composite() ;
dist = Composite() ;
assign = Composite() ;
for i = 1:numChunks;
chunk = i:numChunks:numData ;
data{i} = X(:, chunk) ;
dist{i} = inf(1, numel(chunk), class(X)) ;
assign{i} = zeros(1, numel(chunk)) ;
end
When I run the code, it shows error Undefined operator ':' for input arguments of type 'parallel.Pool'.
First, what mean by that error ? And what should I do to solve this error?
Thank you.

采纳的回答

Steven Lord
Steven Lord 2019-3-3
I suspect you expected parpool to return the number of workers in the pool or something similar. It doesn't. It returns an object representing the pool. That object doesn't know how to behave when used as one of the values in a call to the colon operator (:) -- colon just isn't defined for that object. However it does has a property NumWorkers that contains the number of workers in the pool. So if you want your loop to iterate over the workers:
for i = 1:numChunks.NumWorkers
If that's not what you're trying to do, please explain in more detail what you expect / want numChunks to represent and we may be able to offer some guidance for how to achieve your goal.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by