0

Suppose I have the following example

clear; clc;
N = 10000;
parfor i = 1:N
    inv(pi * eye(100) + randi(10,100));
end

I would like to track the loop's progress. For a sequential loop, I can just print out i (or i/N) but what can I do here please? I tried pre-declaring sum = 0; and then inside the loop, I did

sum = sum + 1;

but I got an error when trying to display sum / N.

yurnero
  • 315
  • 2
  • 9
  • Due to the nature how parallel runs are executed you cannot use the same solution as for sequential runs (see the explanation of the error in your Editor). Take a look at [this](https://www.mathworks.com/matlabcentral/fileexchange/32101-progress-monitor--progress-bar--that-works-with-parfor) File Exchange submission for a working solution. – rozsasarpi Jul 26 '16 at 06:27
  • 1
    Possible duplicate of [Matlab: Print progress from parfor loop](http://stackoverflow.com/questions/23515240/matlab-print-progress-from-parfor-loop) – rozsasarpi Jul 26 '16 at 06:33
  • @Arpi Thanks. I'll take a look. – yurnero Jul 26 '16 at 06:34
  • 1
    by the way avoid to use a function's name for you variable (like sum). – obchardon Jul 26 '16 at 08:16
  • 1
    [PARFOR Progress Monitor v2](https://www.mathworks.com/matlabcentral/fileexchange/31673-parfor-progress-monitor-v2) is quite good. – nirvana-msu Jul 26 '16 at 20:53

0 Answers0