Variable in a parfor cannot be classified
이전 댓글 표시
I'm attempting to convert some code to use a parfor, and have run into difficulty. A simplified example is given below, which doesn't work. I have read the documentation and lots of answers, but nonetheless can't seem to work it out.
% Preallocate array
var1 = zeros(5);
parfor i = 1:5
for j = 2:6
var1(j, :) = j;
end
end
Preallocating the arrays within the parfor gives no errors, but I don't understand why this works but the initial example doesn't. Could someone please put me out of my misery and explain this, or point me to the right bit of documentation? Thanks
parfor i = 1:5
% Preallocate array
var1 = zeros(5);
for j = 2:6
var1(j, :) = j;
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!