Reputation: 497
I have added a waiting bar in matlab by using the following commands, but it want to make a modification.
h = waitbar(0,'Algorithm is running Xth simulation');
N = 30;
for i = 1:N
...
waitbar(i / N)
end;
close(h)
Now, I want to change the waitting bar in such a way that in each loop it shows that "Algorithm is running ith simulation"
Upvotes: 1
Views: 141
Reputation: 18488
According to The Fine Manual of waitbar
, you can pass it a string with an updated message. Formatting a string in which you want to insert some numbers is done the easiest with sprintf
. Example:
n = 10;
h = waitbar(0, sprintf('Starting %i simulations', n));
for i=1:n
pause(1); % pretend to do some work, your simulation code goes here
waitbar(i / n, h, sprintf('Finished the %ith simulation', i))
end
pause(1) % wait a little bit before closing it.
close(h)
Upvotes: 1