cwaitbar.m
无许可证
An extension/generalization of the MATLAB's WAITBAR function. Used when you want to show progress in "nested computations". Supports different coloring of bars other than the default red color. See example below on usage.
%%%%%
CWAITBAR Display compound wait bar.
H = CWAITBAR(X,TITLE) creates and displays wait bars of
fractional lengths X and with one title string TITLE.
The handle to the compound waitbar figure is returned in H.
X values should be between 0 and 1.
Each subsequent call to cwaitbar, CWAITBAR([BAR X]),
extends the length of the bar BAR to the new position X.
The first bar is the topmost bar and is BAR = 1 which
corresponds to the outermost loop.
H = CWAITBAR(X,TITLE) where TITLE is a cellstring with same
number of titles as there are fractional lengths in X.
Suitable for showing the bars' corresponding loop indices.
H = CWAITBAR(X,TITLE,COLOR) where COLOR is the color of the
bars. COLOR is either a color code character (see PLOT) or
an RGB vector. The default color is red. COLOR can also be
a cell array with same number of elements as there are bars
in the cwaitbar figure.
The order of the elements in vector X and cell arrays TITLE
and COLOR which is consistent with the bar number BAR is:
The first element corresponds to the first bar at the top
of the figure which in turn corresponds to the outermost loop.
CWAITBAR is typically used inside nested FOR loops that
performs lengthy computations.
Examples:
cwaitbar([.3 .2 .7],'Please wait...'); %single title
h = cwaitbar([0 0 0],{'i','j','k'},{[.8 .2 .8],'b','r'});
for i=1:5,
% computations %
for j=1:10
% computations %
for k=1:100
% computations %
cwaitbar([3 k/100])
end
cwaitbar([2 j/10])
end
cwaitbar([1 i/5])
end
close(h)
See also WAITBAR.
%%%%%%%%%%%
More functions available at:
http://www.etek.chalmers.se/~e8rasmus/eng/matlab_programs.html
引用格式
Rasmus Anthin (2024). cwaitbar.m (https://www.mathworks.com/matlabcentral/fileexchange/4121-cwaitbar-m), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 | Bar number BAR is now "flipped". BAR = 1, corresponds to the topmost bar and BAR = n, where n is the number of bars, corresponds to the bottom bar (innermost loop). |