Skip to content

HumanNeuronLab/cmdWaitBar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

cmdWaitBar

Matlab function that displays a progression bar in the command window.


This Matlab function will generate an updating progress bar (waitbar) in the command window.

This is a useful tool during data processing over many iterations or time-cosuming computations.

This simple visual feedback allows to track current progress and may also be a valuable tool for debugging and finding with value/entry may be causing an error.

By using simple text output rather than a graphical interface, the computational sacrifice is minimised, which speeds tasks when compared to other waitbars that have graphical outputs.

The waitbar will adapt to the current width of your command window.

View cmdWaitBar on File Exchange



There are 2 viewer modes:

  • Waitbar (viewer mode 1 - default): Good for global progression tracking, fast simple, customisable.
  • Iteration (viewer mode 2): displays current iteration out of total for detailed view on current progress - good for debugging.

NB: best use is to call the cmdWaitBar function at the start of the for-loop in order to get most accurate information for debugging!


Viewer mode: Viewer 1 (default - waitbar) Viewer 2 (Current iteration)
Example code
iStart = 1;
iStop  = 50000;
for i = iStart:iStop
  
  %(customise with e.g: '-')
  cmdWaitBar(iStart,iStop,i)
  
  %[Your code...]
end
iStart = 1;
iStop  = 50000;
for i = iStart:iStop
  
  cmdWaitBar(iStart,iStop,i,2)
  
  %[Your code...]
end
Command window output

Alt Text

Alt Text



How to use:

Within a "for" loop in matlab, insert a call to the function with the following three arguments

  • iStart, the integer the for-loop starts at
  • iStop, the final iterative value
  • i, the current iteration's value

Optional arguments that can be passed to the function:

  • '(char-of-choice)' for the waitbar. Default is '·', such as [···]. Only the first char in a string will be used when passed to the function as an argument (e.g: '-;' will generate [---]).
  • Viewer mode: value 1 or 2. 1 (default) generates the waitbar with a percentage value. 2 generates the current iteration value over iStop (e.g: "Iteration: 72/223").


cmdWaitBar 2022 | Human Neuron Lab - UNIGE | jonathan.monney@unige.ch



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages