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

 Akzeptierte Antwort

Titus Edelhofer
Titus Edelhofer am 7 Dez. 2011

0 Stimmen

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 Kommentar

Marta
Marta am 7 Dez. 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Parallel Computing Toolbox finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by