MATLAB Answers

"unable to classify the variable in the body of the parfor-loop"

62 views (last 30 days)
alpedhuez on 4 Aug 2020
Commented: alpedhuez on 5 Aug 2020
I tried
parfor (a=1:n, 12)
and obtained
Error: Unable to classify the variable 'bidder_samples' in the body of the parfor-loop. For more information, see Parallel for Loops in MATLAB, "Solve Variable Classification Issues in parfor-Loops".
What would be the next step?


Sign in to comment.

Answers (1)

Edric Ellis
Edric Ellis on 5 Aug 2020
The doc page you mention describes the valid ways of getting results out of a parfor loop. In your case, you appear to be computing distinct chunks of column 5 of X based on chunks of columns 3:4 of X. To fit in with the parfor rules though, you must re-write your code a little to make the references into X be compatible with "slicing". One way to do that would be to make X be n-by-b-by-5, and then do something like this (completely untested):
X34 = ones(n, b, 2); % corresponds to X(:,3:4)
Xout = ones(n, b); % corresponds to X(:,5)
parfor a = 1:n
Y = X34(a,:,:);
% compute Z
Xout(a,:) = Z;


alpedhuez on 5 Aug 2020
Essentially, is it that parfor can only deal with a single row operation?
Edric Ellis
Edric Ellis on 5 Aug 2020
The restrictions of parfor sliced indexing are that you slice an array in a single dimension, and that the index in that dimension must be the loop variable (possibly with a constant offset, but that's not relevant here).

Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by