File Exchange

image thumbnail

Progress Meter for Execution of Tasks/Loops

version (2.23 KB) by Ameya Deoras
Include simple calls to PROGMETER in your code to display its progress in the command window.

1 Download

Updated 01 Sep 2016

View Version History

View License

PROGMETER enables you to display the completion of a task or loop dynamically in the command window. The progress meter is displayed as text of the form,
>> Task Description: 45%
where the completion level can be modified with subsequent calls to the function. Its usage is similar to that of WAITBAR.
PROGMETER(x, message) will create a new progress meter by displaying the string variable message and the progress represented as a percentage based on x. x can take values between 0 and 1 where 1 implies 100% completion. If a progress meter already exists, this will update the existing progress meter with the new message and progress value calculated from x.

PROGMETER(x) will update the progress meter with the new value in x without changing the message of an existing progress meter. If a new progress meter is created it will not display any message, just the progress.

PROGMETER done will update the progress meter to "Done" and reset the internal state

PROGMETER clear will erase the meter and message and reset the internal state

PROGMETER reset will not update the meter but reset the internal state

When the internal state is reset, subsequent calls to progmeter will display text on a new line. Note that any other text displayed to the MATLAB command window between calls to progmeter can result in undesired behavior.

progmeter(0, 'Running through pauses')
for i = 1:20
progmeter done

% This loop is 67% of the processing
for i = 1:20
progmeter((i-1)/20*.67, 'Processing Task (loop 1)');
% Do some operation and pretend it takes .2 seconds
% This loop is 33% of the processing
for i = 1:10
progmeter((i-1)/10*.33 + .67, 'Processing Task (loop 2)');
% Do something else and pretend it takes .2 seconds
progmeter reset

Cite As

Ameya Deoras (2021). Progress Meter for Execution of Tasks/Loops (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

kasim tasdemir


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:

***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

11:25:37 Begining the process...
11:25:37 Progress 100%

All the best

Arturo Serrano

B. J.

Download is not working...

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!