For normal for-loops the simple waitbar command works well.
waitbar(0)
for i=1:N
waitbar(i/N)
...do something
end
however it doesn't work with the parfor loops, since things
aren't done in order.
Has anybody made a function or found a work-around?
Thanks
Will
Currently, there is unfortunately no way of receiving
notification in the MATLAB client when an iteration is
completed on a worker.
Best,
Narfi
"William Dampier" <wal...@gmail.com> wrote in message
<fs0m5p$nkd$1...@fred.mathworks.com>...
I've tried something along these lines so far, maybe it will
inspire someone with more knowledge of the callback systems.
N=100;
BEEN_DONE_VEC=false(N,1)
wait_handle=waitbar(0);
parfor (IND=1:N)
BEEN_DONE_VEC(IND)=true;
waitbar(wait_handle,mean(BEEN_DONE_VEC))
...do something
end
In this case it doesn't matter that the operations are not
done in order, since it just updates it with the fraction of
instances that are completed. The only problem I have is
figuring out how to pass an 'update' type call to waitbar.
"Narfi " <narfi.st...@mathworks.com> wrote in message
<fs0tg5$qdq$1...@fred.mathworks.com>...
I had a similar idea. Matlab did not accept it though, since it will regard the mean(...) command (I used sum(...)) as something inconsistent as it varies with the order of the parfor loop execution - of which all results of course should be independent.
I thought of something more basic then:
fprintf(repmat('*',1,N));
parfor ind = 1 : N
fprintf('\b')
...
end
if N is too large fractioning is be necessary. Its crude but it works.
fractioning in parts n, choose n appriopriatly:
M = numel(find(mod(1:N,n)==0));
fprintf(repmat('*',1,M));
parfor ind = 1 : N
if mod(ind,n)==0; fprintf('\b'); end
...
end
function testParFor()