How can I degug inside a parfor loop?
62 ビュー (過去 30 日間)
表示 古いコメント
When I insert breakpoints inside a parfor loop it is never stopped. In this case how can I debug inside a parfor loop?
2 件のコメント
採用された回答
Edric Ellis
2017 年 10 月 30 日
You can debug code called from the body of a parfor loop if no parallel pool is open, but unfortunately you cannot debug the body of a parfor loop itself. You can force the parfor loop to run in the desktop MATLAB by appending the optional "number of workers" argument, like so:
parfor (idx = 1:10, 0)
out(idx) = myFcn(idx);
end
With that code, you can set breakpoints inside myFcn.
その他の回答 (2 件)
NAGAVARSHINI MAYAKKANNAN
2020 年 6 月 21 日
Change the parfor to for debug it and then change for to parfor
0 件のコメント
zhehao.nkd
2022 年 8 月 5 日
For those who are seeking for the solution, there is another possible option by using parfor and try-catch:
parfor k = 1: len
try
% your code
catch ME
% record the iteration index,k
end
end
% Then youy know which iteration caused a bug alert
0 件のコメント
参考
カテゴリ
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!