How can I debug parfor loop to find out where an error comes from?

6 views (last 30 days)
Hi. I am trying to run a specific code 15 times, each time for a new set of data so my iterations are not sequential. I use SPM toolbox and am trying to speed up the calculations using matlabpool and parfor. In each iteration, a temporary structure variable (DCM) is initialised then sent to a function to return the output to the same variable (DCM). At the end of each parfor iteration, the estimated DCM is saved on the disk as DCM_i and it is worth mentioning that the analysis time for different datasets is different. When I ran the code for 15 datasets, it loaded 8 datasets randomly and I could see (according to the script I have written) when one of the sets was finished in a lab, another one would be loaded. So, after 7 of datasets were analysed and their DCM's were saved on the disk, suddenly I got a similar error to the following:
Error in converting struct to double => It is not possible to change struct to double
Now I have no idea where this error happens. All my datasets are exactly the same and the same code has been applied on all of them using for loop. As my parfor loop is working now and it has given me the results of some of the datasets, I don't get it why I would receive such a basic error. I feel I should have received the same error for all datasets if there was a coding mistake.
Best, Pegah
  5 Comments
Walter Roberson
Walter Roberson on 30 Aug 2012
When the pool is not open, "for" is used instead of "parfor". Except that the iterations might not be done in the same order as if "parfor" had not been specified.
Pegah Hosseini
Pegah Hosseini on 30 Aug 2012
So is it possible that the way I define the parameters in the above code is not suitable for parfor?

Sign in to comment.

Answers (0)

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!