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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de En. de 2012

0 votos

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

Más respuestas (1)

Edric Ellis
Edric Ellis el 16 de En. de 2012

0 votos

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 comentario

Facosoft
Facosoft el 16 de En. de 2012
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

Iniciar sesión para comentar.

Categorías

Productos

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by