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
采纳的回答
更多回答(1 个)
Edric Ellis
2012-1-16
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
类别
在 帮助中心 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!