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

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 12월 7일

0 개 추천

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

Marta
Marta 2011년 12월 7일
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

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by