The variable in a parfor cannot be classified, parfor

조회 수: 7 (최근 30일)
Marc Paul
Marc Paul 2018년 1월 18일
댓글: Marc Paul 2018년 1월 19일
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

채택된 답변

Adam
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
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.
Marc Paul
Marc Paul 2018년 1월 19일
You're right. I clicked only the link in my mail to accept the answer and thought thtat's it. Sorry. Already corrected :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by