From: Bas van der Linden on
You can (ab)use Java's synchronized containers for this. For example, if the array itself isn't too big, an approach would be

---
s = []; % Clear so java class can be reloaded if needed
s = java.util.Collections.synchronizedSet(java.util.HashSet());

n = length(array,1);
parfor i = 1:n
% Add i to hash set so we know how far we are
add(s,i);
ii = s.size();
fprintf('i = %d, sequence number = %d, total = %d)\n', i, ii, n);
some_result(i) = somefunc(array(i,:));
end
---

Of course you can write your own class that doesn't need to store the indices, but by using standard java classes you avoid having to add directories to the class path etc. For a quick progress update, this seems fancy enough...

"Daniel Goodman" <dbgoodman(a)gmail.com> wrote in message <gqap1j$jqe$1(a)fred.mathworks.com>...
> I have a parfor loop that operates on slices of a large array:
> ---
> parfor i = 1:length(array)
> some_result(i) = somefunc(array(i,:))
> end
> ---
>
> Any ideas?
From: Bas van der Linden on
Unfortunately, having a closer look at the output, it doesn't work. The java object is copied over different workers and so we aren't adding to the same set. So it seems that the socket solution at is to only (complicated) way to do it&#8230; See <http://www.mathworks.com/matlabcentral/fileexchange/24594-parfor-progress-monitor>.

> ---
> s = []; % Clear so java class can be reloaded if needed
> s = java.util.Collections.synchronizedSet(java.util.HashSet());
>