Transparency violation

Hi,
I have this code segment within a parfor ... end loop. Error flagged off, complaining about the way LT is used, so the code would not run.
% I have 8 workers
matlabpool open local 8
parfor n=1:100
.
. % other codes here
.
yt = UT + round ((Long(n)/15)*60);
for i=1:1440
if yt(i) <= 1440;
LT(i) = yt(i);
elseif yt(i) > 1440
LT(i) = yt(i)-1440;
end;
end;
.
. % other codes here too
.
end % parfor end
matlabpool close
I read some helpful note, transparency error and variable classification error were referred to, but could still not resolve the problem.
So, I may need to slice the variable LT or so. Kindly help to fix this code.
Felix

 채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 14일

0 개 추천

Perhaps use logical indexing?
yt = UT + round ((Long(n)/15)*60);
LT = yt;
LT(LT>1440) = LT(LT>1440)-1440;

추가 답변 (1개)

Edric Ellis
Edric Ellis 2012년 1월 16일

0 개 추천

You're not indexing 'LT' with the loop variable, so it can never be 'sliced'. Are you calculating the whole of 'LT' each time around your main PARFOR loop? If so, it might help to pre-allocate it so that PARFOR knows you're not trying to use it in an order-dependent way. Something like
parfor n = 1:100
LT = zeros(1,1440);
for i = 1:1440
% do stuff
end
end

댓글 수: 1

Facosoft
Facosoft 2012년 1월 16일
I thank you. The solution provided would cause unnecessary communication overhead when dividing the work among the lab workers...Indexing is just not enough but would at least handle the error. Thanks

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

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by