File Exchange

image thumbnail

ASCII Progress Bar

version (1.91 KB) by

An ASCII progress bar with timers.

1 Download


View License

This is a relatively powerful ASCII progress bar with indicators of time.
It works under Windows and Linux.

Comments and Ratings (8)

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

code improvement

% (1) Set this to the total number of iterations

progress_bar_position = 0;

time_for_this_iteration = 0.01;
% (2) Provide initial time estimate for one iteration

for i=1:max,

% (3) Place all computations here

progress_bar_position = progress_bar_position + 1 / max;
progress_string =['|' repmat('#',[1 round(49*(progress_bar_position))])...
repmat(' ',[1 round(49*(1-progress_bar_position))]) '|'] ;

disp(['|================ ',num2str(floor(progress_bar_position * 100),'%0.3u'),...
'% completed =================|']);
% display progress per cent
steps_remaining = max - i;
minutes = floor(time_for_this_iteration * steps_remaining / 60);
seconds = rem(floor(time_for_this_iteration * steps_remaining), 60);
disp(' ');

disp([' Estimated remaining time: ',...
num2str(minutes,'%0.2u'), ':', num2str(seconds,'%0.2u')]);

time_for_this_iteration = toc;

W. Th.

Great idea

Oleksandr Zozulya

Note that variable "max" is actually a function in a Matlab, therefore it is strongly advised not to use it.

Hugo Hidalgo

Nice tool. If the following lines are added after the calculation and before the "clc" command, you don't need an initial estimate for completing one iteration. The progess bar will be printed after the first iteration is completed.

if i==1
time_for_this_iteration = toc;

Harvey Tobkes


BSD License

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

Inspired: Another ASCII Progress Bar

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

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

» Watch video