Error: Unable to classify a variable in the body of the parfor-loop
Show older comments
hello everyone,
I have the following code:
parfor i = 1:2^NJ-1
struct(i,:) = dec2bin(i,NJ);
end
M1 = 0;
for i = 1:NJ
R_M1 = 0;
for j = 1:2^NJ-1
temp = 0;
for p = 1:NJ
temp = temp + str2num(struct(j,p));
end
if temp == i
R_M1 = R_M1 + 1;
final(R_M1,:) = struct(j,NJ:-1:1);
end
M1 = R_M1
end
end
As it is, the code works fine but I want to change the loop after "M1=0" and change the first "For"(for i = 1:NJ) to "Parfor"(parfor i = 1:NJ) but when I do this and run the code I get the following error:
"Error: Unable to classify the variable 'final' in the body of the parfor-loop. For more information, see Parallel for Loops in MATLAB, "Solve Variable Classification Issues in parfor-Loops"."
I think it may be due to the use of "struct(j,NJ:-1:1)" inside the "parfor" loop. Any help would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!