4.0

4.0 | 1 rating Rate this file 85 downloads (last 30 days) File Size: 3.09 KB File ID: #21887

Progress Meter for Execution of Tasks/Loops

by Ameya Deoras

 

25 Oct 2008 (Updated 13 Apr 2009)

BSD License  

Include simple calls to PROGMETER in your code to display its progress in the command window.

Download Now | Watch this File

File Information
Description

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.  
 
Examples:  
%1. SINGLE LOOP:  
clc  
progmeter(0, 'Running through pauses')  
for i = 1:20  
    pause(.2);  
    progmeter(i/20);  
end  
progmeter done  
 
% MULTIPLE LOOPS:  
% 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  
    pause(.2);  
end  
% 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  
    pause(.2);  
end  
progmeter reset

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
17 Nov 2008 Becky J. Download is not working...
07 Jan 2009 Arturo Serrano  
Please login to add a comment or rating.
Updates
27 Oct 2008 Minor fix to progmeter clear codepath
13 Apr 2009 Fixed a minor bug - a variable was being cleared before it should have been
Tag Activity for this File
Tag Applied By Date/Time
waitbar Ameya Deoras 27 Oct 2008 09:29:52
progress bar Ameya Deoras 27 Oct 2008 09:29:52
progress text Ameya Deoras 27 Oct 2008 09:29:52
completion Ameya Deoras 27 Oct 2008 09:29:52
meter Ameya Deoras 27 Oct 2008 09:29:52

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com