parfor with wrong indexing. Trying to assign output to parts of vector
이전 댓글 표시
Hi,
I'm trying to run a parfor loop, but I don't know how to index one of the variables. The code is the following
tt=data(:,1);
xi=zeros(max(size(tt)),1);
parfor t=1:max(time)
xik=xi0(tt==t,1);
tk=nj(time==t,1);
ik=idt(time==t,1);
all_kk=z(time==t,:);
agg_kk=data(tt==t,4);
error=1;
while error>tol
xi0k=xik;
j=ll(xi0k,tk,ik,d,zz);
xik=xi0k+log(agg_kk)-log(j);
error=max(abs(xik-xi0k));
end
xi(tt==t,1)=xik;
end
Before the 'while' loop, the code loads 'pieces of data' that correspond to the part of each vector associated with 't'. Then, I use the while loop for each of these t's separately. The first issue is that because of the way in which I'm assigning the part of each vector associated with t, I get the message "The variable is indexed, but not slide". Could anybody suggest how to avoid having the whole vector being sent to each worker? Second, and much more important, the last part of the code takes each piece xik associated with each t, and (tries to) put it into the part that it corresponds, according to t, in the vector xi; and this is not allowed, at least in this form, for a parfor loop. Does anybody have a suggestion of how to deal with this?
Thanks,
채택된 답변
추가 답변 (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!