[![View MatlabProgressBar on File
Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://de.mathworks.com/matlabcentral/fileexchange/57895-matlabprogressbar)
# MatlabProgressBar
- [MatlabProgressBar](#matlabprogressbar)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Usage](#usage)
- [Proposed Usage for Simple Loops](#proposed-usage-for-simple-loops)
- [Extended Usage with all Features](#extended-usage-with-all-features)
- [Parallel Toolbox Support](#parallel-toolbox-support)
- [Known Issues](#known-issues)
- [Flickering Bar or Flooding of the Command Window](#flickering-bar-or-flooding-of-the-command-window)
- [The Bar Gets Longer With Each Iteration](#the-bar-gets-longer-with-each-iteration)
- [Strange Symbols in the Progress Bar](#strange-symbols-in-the-progress-bar)
- [Remaining Timer Objects in MATLAB's Background](#remaining-timer-objects-in-matlabs-background)
- [Issues Concerning Parallel Processing](#issues-concerning-parallel-processing)
- [Unit Tests](#unit-tests)
- [License](#license)
This project hosts the source code to the [original MATLAB FileExchange
project](https://de.mathworks.com/matlabcentral/fileexchange/57895-matlabprogressbar)
and is place of active development.
A drawback in MATLAB's own `waitbar()` function is the lack of some functionalities and
the loss of speed due to the rather laggy GUI updating process. Therefore, this MATLAB
class aims to provide a smart progress bar in the command window and is optimized for
progress information in simple iterations or large frameworks with full support of
parallel *parfor* loops and asynchronous processing via *parfeval()* provided by the
MATLAB Parallel Computing Toolbox.
A design target was to mimic the best features of the progress bar
[tqdm](https://github.com/tqdm/tqdm) for Python. Thus, this project features a
Unicode-based bar and some numeric information about the current progress and the
average iterations per second.
Several projects exist on MATLAB's [File
Exchange](https://www.mathworks.com/matlabcentral/fileexchange/?term=progress+bar) but
none incorporates the feature set shown below. That's why I decided to start this
project.
![Easy progress bar example](images/example2.gif)
**Supported features include (or are planned)**:
- [x] proper unit testing
- [x] display the bar name as a ticker. That way, a fixed bar width could be used
- [x] inherit from MATLAB System Object to gain benefits from the setup method
- [ ] use [this new functionality](https://de.mathworks.com/help/distcomp/send.html)
for the parallel implementation. Introduced in R2017a.
- [x] TQDM Unicode blocks
- [x] optional constructor switch for ASCII number signs (hashes)
- those will be used if `ProgressBar()` is used in deploy mode (MATLAB Compiler)
- [x] optional bar title
- [x] optional visual update interval in Hz [defaults to 10 Hz]
- [x] when no total number of iterations is passed the bar shows the elapsed time, the
number of (elapsed) iterations and iterations/s
- [x] nested bars (at the moment only one nested bar is supported [one parent, one
child])
- [x] `printMessage()` method for debug printing (or the like)
- [x] print an info when a run was not successful
- [x] support another meaningful 'total of something' measure where the number of items
is less meaningful (for example non-uniform processing time) such as total file size
(processing multiple files with different file size). At the moment, the only
alternative supported unit is `Bytes`
- [x] when the internal updating process is faster than the actual updates via
`update()`, the internal counter and printing of the process bar stops until the next
update to save processing time
- [x] linear ETA estimate over all last iterations
- [x] support parfor loops provided by the Parallel Computing Toolbox
- [x] show s/it if it/sec < 1
- [x] override MATLAB's default non-UTF font if `OverrideDefaultFont` is `true`. This
will switch the font for the command line to `Courier New` for the lifetime of the
bar. Default is `false`
- [x] disable the progress bar if `IsActive` is `false`. This will disable the
functionality completely and can be used in situations in which the bar is not
beneficial (e.g. if the bar is used in a sub-application of a processing cluster).
Default is `true`.
**Note**:
Be sure to have a look at the [Known Issues](#known-issues) section for current known
bugs and possible work-arounds.
## Dependencies
No dependencies to toolboxes.
The code has been tested with MATLAB R2016a, R2016b and R2020b on Windows 10, Xubuntu
16.04.2 LTS and Linux Mint 20.
## Installation
Put the files `ProgressBar.m`, `progress.m` and `updateParallel.m` into your MATLAB path
or the directory of your MATLAB project.
## Usage
Detailed information and examples about all features of `ProgressBar` are stated in the
demo scripts in the `./demos/` directory.
### Proposed Usage for Simple Loops
The simplest use in `for`-loops is to use the `progress()` function. It wraps the main
`ProgressBar` class and is intended to only support the usual progress bar. Be aware
that functionalities like `printMessage()`, printing success information or a step size
different to 1 are not supported with `progress.m`. Also, this only works for
**non-parallel** loops.
See the example below:
```matlab
numIterations = 10e3;
% create the loop using the progress() class
for iIteration = progress(1:numIterations)
% do some processing
end
```
![Example 2](images/example2.gif)
### Extended Usage with all Features
The basic work flow is to instantiate a `ProgressBar` object and use either the `step()`
method to update the progress state (MATLAB <= R2015b) or use the instantiated object
directly as seen below. Refer to the method's help for information about input
parameters. The shown call is the *default* call and sufficient. If you want to pass
information about the step size, the iteration's success or if a new bar should be
printed immediately (e.g. when iterations take long time) you can pass these information
instead of empty matrices.
All settings are done using *name-value* pairs in the constructor. It is **strongly
encouraged** to call the object's `release()` method after the loop is finished to clean
up the internal state and avoid possibly unrobust behavior of following progress bars.
*Usage*
`obj = ProgressBar(totalIterations, varargin)`
A simple but quite common example looks like this:
```matlab
numIterations = 10e3;
% instantiate an object with an optional title and an update
% rate of 5 Hz, i.e. 5 bar updates per seconds, to save
% printing load.
progBar = ProgressBar(...
numIterations, ...
'Title', 'Awesome Computation' ...
);
% begin the actual loop and update the object's progress
% state
for iIteration = 1:numIterations
%%% do some processing here
% ...
progBar([], [], []);
% or in releases <= R2015b
% progBar.step([], [], []);
end
% call the 'release()' method to clean up
progBar.release();
```
![Extended usage with the object method calls](images/example1.gif)
### Parallel Toolbox Support
If you use MATLAB's Parallel Computing Toolbox, refer to the following example or the
demo file `k_parallelSetup.m`. Tested parallel functionalities are `parfor` and
`parfeval()` for asynchronous processing.
```matlab
numIterations = 10e3;
% Instantiate the object with the 'IsParallel' switch set to true
progBar = ProgressBar(numIterations, ...
'IsParallel', true, ...
'Title', 'Parallel Processing' ...
);
% ALWAYS CALL THE SETUP() METHOD FIRST!!!
progBar.setup([], [], []);
parfor iIteration = 1:numIterations
pause(0.1);
% USE THIS FUNCTION AND NOT THE STEP() METHOD OF THE OBJECT!!!
updateParallel([], pwd);
end
progBar.release();
```
As of `v3.4.0`, you can also nest the loops so that the inner one uses a `parfor` loop.
## Known Issues
### Flick
没有合适的资源?快使用搜索试试~ 我知道了~
此MATLAB类在命令窗口中提供了像tqdm这样的智能进度条,并针对简单itera中的进度信息进行了优化….zip
共20个文件
m:14个
md:2个
gif:2个
需积分: 3 0 下载量 38 浏览量
2024-03-09
15:12:04
上传
评论
收藏 81KB ZIP 举报
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。 Matlab(Matrix Laboratory)是一种专为数值计算和科学与工程应用而设计的高级编程语言和环境。在算法开发和实现方面,Matlab具有以下一些好处: 1. 丰富的数学和科学函数库:Matlab提供了广泛的数学、信号处理、图像处理、优化、统计等领域的函数库,这些函数库可以帮助开发者快速实现各种复杂的数值计算算法。这些函数库提供了许多常用的算法和工具,可以大大简化算法开发的过程。 2. 易于学习和使用:Matlab具有简单易用的语法和直观的编程环境,使得算法开发者可以更快速地实现和测试他们的算法。Matlab的语法与数学表达式和矩阵操作非常相似,这使得算法的表达更加简洁、清晰。 3. 快速原型开发:Matlab提供了一个交互式的开发环境,可以快速进行算法的原型开发和测试。开发者可以实时查看和修改变量、绘制图形、调试代码等,从而加快了算法的迭代和优化过程。这种快速原型开发的特性使得算法开发者可以更快地验证和修改他们的想法。 4. 可视化和绘图功能:Matlab具有强大的可视化和绘图功能,可以帮助开发者直观地展示和分析算法的结果。开发者可以使用Matlab绘制各种图形、曲线、图像,以及创建动画和交互式界面,从而更好地理解和传达算法的工作原理和效果。 5. 并行计算和加速:Matlab提供了并行计算和加速工具,如并行计算工具箱和GPU计算功能。这些工具可以帮助开发者利用多核处理器和图形处理器(GPU)来加速算法的计算过程,提高算法的性能和效率
资源推荐
资源详情
资源评论
收起资源包目录
此MATLAB类在命令窗口中提供了像tqdm这样的智能进度条,并针对简单itera中的进度信息进行了优化….zip (20个子文件)
MatlabProgressBar-master
ProgressBar.m 33KB
updateParallel.m 3KB
LICENSE 2KB
progress.m 3KB
tests
progress_test.m 2KB
ProgressBar_test.m 8KB
CHANGELOG.md 3KB
.gitignore 11B
images
example1.gif 37KB
example2.gif 30KB
demos
parallelSetup.m 1KB
printInfoDuringRun.m 570B
nestedProgressBars.m 2KB
passSuccessInfo.m 634B
basicUseCases.m 2KB
disableBar.m 431B
titleBanner.m 601B
countProcessedBytes.m 1KB
nonUnicodeProgressBar.m 418B
README.md 12KB
共 20 条
- 1
资源评论
若明天不见
- 粉丝: 1w+
- 资源: 272
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功