I modified parfor_progress written by Jeremy Scheff File ID: #32101 to allow for multiple instances being run in the same folder.
%PROGRESSBAR Progress bar class for matlab loops which also works with parfor.
% PROGRESSBAR works by creating a file called progressbar_(random_number).txt in
% your working directory, and then keeping track of the loop's
% progress within that file. This workaround is necessary because parfor
% workers cannot communicate with one another so there is no simple way
% to know which iterations have finished and which haven't.
% METHODS: ProgressBar(num); constructs an object and initializes the progress monitor
% for a set of N upcoming calculations.
% progress(); updates the progress inside your loop and
% displays an updated progress bar.
% stop(); deletes progressbar_(random_number).txt and finalizes the
% progress bar.
% N = 100;
% p = ProgressBar(N);
% parfor i=1:N
% pause(rand); % Replace with real code
% p.progress; % Also percent = p.progress;
% p.stop; % Also percent = p.stop;
% To suppress output call constructor with optional parameter 'verbose':
% p = ProgressBar(N,'verbose',0);
% To get percentage numbers from progress and stop methods call them like:
% percent = p.progress;
% percent = p.stop;
% By: Stefan Doerr
% Based on: parfor_progress written by Jeremy Scheff File ID: #32101
@Mattias I updated now the function to not use rm. So it should work now in Windows too
@Mattias Hm yes sorry, I guess it only works for Linux where I tested it. You can replace the "rm" command with "del" and it should work in Windows too.
This works great, the only problem is the p.stop command doesn't seem to be working.
I get a message saying "'rm' is not recognized as an inter" and the text file is still there.
I use 'dispstat' function just for this purpose. It can update the previous output which is a missing function of default 'disp'. Very simple to use. It can be downloaded from here:
dispstat('','init'); % One time only initialization
dispstat(sprintf('Begining the process...'),'keepthis','timestamp');
for i = 97:100
%doing some heavy stuff here
11:25:37 Begining the process...
11:25:37 Progress 100%
All the best
Replaced system('rm') with matlab delete function to make compatible with windows
Removed dependency on the statistics toolbox for the varargin
I renamed the output file and added more detailed description