MATLAB Answers

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

조회 수: 66(최근 30일)
alpedhuez 4 Aug 2020
댓글: alpedhuez 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?

  댓글 수: 0

댓글을 달려면 로그인하십시오.


Edric Ellis
Edric Ellis 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;

  댓글 수: 3

alpedhuez 5 Aug 2020
Essentially, is it that parfor can only deal with a single row operation?
Edric Ellis
Edric Ellis 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).

댓글을 달려면 로그인하십시오.


Community Treasure Hunt

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

Start Hunting!

Translated by