anonymous functions and parfor

Hi,
I would like to transform a for loop into a parfor loop. In the for loop I am solving a delayed differential equation via heun method, which means that i am sending the function to be solved as an argument to the heun method.
for nRuns = 1:Nr_runs
res = heunDDE(@function_to_solve, t0, tf, tau,rand, Npoints);
end
With the for loop, i obtain the solution to the DDE without correctly. However, whenever i transform the loop into a parfor, i get:
?? Error using ==> parallel_function at 598
Error in ==> function_to_solve at 9
Index exceeds matrix dimensions.
So what may be my problem here?
Thanks for your help,
Marta

 Risposta accettata

Titus Edelhofer
Titus Edelhofer il 7 Dic 2011

0 voti

Hi Marta,
difficult to say. Since the code fails in line 9 of function_to_solve you might put a disp(size()) commands of variables involved in the computation in line 9 to find out what's the difference when calling using for and parfor ...
Titus

1 Commento

Marta
Marta il 7 Dic 2011
Hi Titus,
thanks a lot for your answer, your intuition was totally right (was emptying the variable somewhere in between the runs).
Million thanks!
Marta

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Parallel Computing Toolbox in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by