How can I degug inside a parfor loop?
52 views (last 30 days)
Edric Ellis on 30 Oct 2017
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);
With that code, you can set breakpoints inside myFcn.
More Answers (2)
NAGAVARSHINI MAYAKKANNAN on 21 Jun 2020
Change the parfor to for debug it and then change for to parfor
zhehao.nkd on 5 Aug 2022
For those who are seeking for the solution, there is another possible option by using parfor and try-catch:
parfor k = 1: len
% your code
% record the iteration index,k
% Then youy know which iteration caused a bug alert