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

サインインしてコメントする。

カテゴリ

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by