The variable in a parfor cannot be classified, parfor
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi, I have tried to convert my problem in a simple form. I know that I have to take care of the indexing in parfor loops, but I don't know how can avoid the problem that one line depends on the previous one. Please check the code and you will understand. Hope you can help me Marc
num_col = 1000;
days_simulation = 400;
SimulationPQ = nan(days_simulation,num_col);
Ergebnis = nan(days_simulation,num_col);
Ergebnis (1,:) = ones(1,num_col);
parfor kk=1:100
for simday = 1:400
SimulationPQ(simday,kk) = rand();
Ergebnis(simday+1,kk) = Ergebnis(simday,kk) * SimulationPQ(simday,kk) ;
end
end
댓글 수: 0
채택된 답변
Adam
2018년 1월 18일
편집: Adam
2018년 1월 18일
Something similar to this should work (it gives no M-Lint warnings at least)
num_col = 1000;
days_simulation = 400;
SimulationPQ = nan(days_simulation,num_col);
Ergebnis = nan(days_simulation,num_col);
Ergebnis (1,:) = ones(1,num_col);
parfor kk=1:100
localErgebnis = Ergebnis(:,kk)
for simday = 1:399
SimulationPQ(simday,kk) = rand();
localErgebnis(simday+1) = localErgebnis(simday) * SimulationPQ(simday,kk) ;
end
Ergebnis(:,kk) = localErgebnis;
end
except that simday+1 will go out of range, but that is just a general problem with your example, nothing to do with the parallel processing aspect.
댓글 수: 3
Jan
2018년 1월 19일
Marc: if this answer solves your problem, please accept it. Then the readers in the forum can see, that you do not need help anymore. Thanks.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!