The variable in a parfor cannot be classified, parfor

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

 Réponse acceptée

Adam
Adam le 18 Jan 2018
Modifié(e) : Adam le 18 Jan 2018
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 commentaires

Marc Paul
Marc Paul le 18 Jan 2018
Modifié(e) : Marc Paul le 19 Jan 2018
It works! Thank you Adam. Have a nice weekend
Jan
Jan le 19 Jan 2018
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.
You're right. I clicked only the link in my mail to accept the answer and thought thtat's it. Sorry. Already corrected :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by