File Exchange

image thumbnail

progress bar

version 1.1 (1.79 KB) by

This function print on your command window a handmade progress bar.

0 Downloads

Updated

View License

If you have a time consuming loop, you can measure the time to end with this function. The only thing you have to know is the total number of loops to do.
For instance if you use:
>>for j = 1:10^6
>>statement;
>>progress_bar(j, 10^6);
>>end
you get the same result in screenshot.

Comments and Ratings (5)

Jan Keller

doesn't output anything

kasim tasdemir

Hi,

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:

http://www.mathworks.com/matlabcentral/fileexchange/44673

***Sample usage:
dispstat('','init'); % One time only initialization
dispstat(sprintf('Begining the process...'),'keepthis','timestamp');
for i = 97:100
dispstat(sprintf('Progress %d%%',i),'timestamp');
%doing some heavy stuff here
end
dispstat('Finished.','keepprev');

***Output:
11:25:37 Begining the process...
11:25:37 Progress 100%
Finished.

All the best

kasim tasdemir

Hi,

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: http://www.mathworks.com/matlabcentral/fileexchange/44673-overwritable-message-outputs-to-commandline-window

***Sample usage:
dispstat('','init'); % One time only initialization
dispstat(sprintf('Begining the process...'),'keepthis','timestamp');
for i = 97:100
dispstat(sprintf('Progress %d%%',i),'timestamp');
%doing some heavy stuff here
end
dispstat('Finished.','keepprev');

***Output:
11:25:37 Begining the process...
11:25:37 Progress 100%
Finished.

All the best

Rob Campbell

Rob Campbell (view profile)

The waitbar can be annoying at times, so I see why this would be a nice function to have. Unfortunately is has to clear the screen to work. Personally, I prefer sticking an fprintf('.') in the loop so that I can see the progress. Simple but effective.

Jason Kaeding

Why not use built-in waitbar function?

Updates

1.1

A third optional input parameter is added. it is useful if embedding the progress_bar function within another function in order to visualize for instance its name (e.g. see screenshot).

MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video