Is it possible to have multiple waitbars in nested FOR loops in MATLAB 6.5 (R13)?

3 views (last 30 days)
Using the WAITBAR function, I would like to have multiple waitbars in nested FOR loops. I would like to know if there is an example of how to do this.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The code below is an example of creating multiple waitbars in nested FOR loops.
% Create bar for outer loop
h1 = waitbar(0,'I waitbar Please wait...');
for i=1:100
% Create bar for inner loop
h2=waitbar(0,'J waitbar Please wait...');
% Change position of second bar so the is not overlap
pos_w1=get(h1,'position');
pos_w2=[pos_w1(1) pos_w1(2)+pos_w1(4) pos_w1(3) pos_w1(4)];
set(h2,'position',pos_w2,'doublebuffer','on')
% Scroll through first waitbar
for j=1:100
waitbar(j/100,h2)
end
% Scroll through second waitbar
waitbar(i/100,h1)
% Close first waitbar, recreate in each iteration of outer loop
close(h2)
end
% Close final waitbar
close(h1)

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!