if else is not working correctly inside parfor loop
이전 댓글 표시
If I run the following piece of code using for loop, it woks fine. But when I am using the same with parfor I get an error.
Code snippet:
vhFlag = 3;
nCores = 8;
matlabpool(nCores)
parfor id = 1 : obj.patchNum
if(3 == vhFlag)
% fetch each patch from the list for matrix creation
patch = testMat(:,:,id);
else
% randomely choose a patch id
patchCounter = ceil(rand(1) * 100);
% get the corresponding patch (original or resynthesized)
patch = StimuliGeneration.GetAPatch(patchListBest, ...
patchCounter, sz-1,
vhFlag);
testMat(:,:,id) = patch; %%to test
end
mat(:, id) = patch(:);
end
matlabpool close
Error : Starting matlabpool using the 'local' configuration ... connected to 8 labs.
??? Undefined function or variable "patchListBest".
Error in => StimuliGeneration>StimuliGeneration.CreatePatchMatrix at 48
parfor id = 1: obj.patchNum
댓글 수: 1
Edric Ellis
2013년 7월 10일
Is 'patchListBest' a function or a variable?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!