Question: I am running a parfor loop in Matlab that takes a lot of time and I would like to know how many iterations are left. How can I get that info?

Answer: 
With Matlab 2017a or later you can use a [data queue](https://se.mathworks.com/help/distcomp/parallel.pool.dataqueue.html) or a [pollable data queue](https://se.mathworks.com/help/distcomp/parallel.pool.pollabledataqueue.html) to achieve this. Here's the MathWorks documentation example of how to do a progress bar from the first link :

```
function a = parforWaitbar

D = parallel.pool.DataQueue;
h = waitbar(0, 'Please wait ...');
afterEach(D, @nUpdateWaitbar);

N = 200;
p = 1;

parfor i = 1:N
    a(i) = max(abs(eig(rand(400))));
    send(D, i);
end

    function nUpdateWaitbar(~)
        waitbar(p/N, h);
        p = p + 1;
    end
end

```

End result : 

[![A picture of the resulting wait bar](https://i.stack.imgur.com/bLeIQ.jpg)](https://i.stack.imgur.com/bLeIQ.jpg)
I created a utility to do this:

<http://www.mathworks.com/matlabcentral/fileexchange/48705-drdan14-parforprogress>