A Message Box for a Nested Loop to Report Progress?

5 visualizaciones (últimos 30 días)
Rightia Rollmann
Rightia Rollmann el 8 de Mzo. de 2017
Respondida: Guillaume el 8 de Mzo. de 2017
I have a nested loop that takes minutes to finish. I want to put a piece of code in the position of Statement2 to know about the progress of the loop (i.e., every iteration of “i” roughly equals 10 percent of the whole progress).
1) Any suggestion for a message box that shows me the progress? 2) How can I generally estimate the time a loop needs to finish?
for i = 1 : 10
for j = 1 : 200
Statement1
end
Statement2
end

Respuestas (1)

Guillaume
Guillaume el 8 de Mzo. de 2017
"How can I generally estimate the time a loop needs to finish"
You can't.
"Any suggestion for a message box that shows me the progress"
Use a waitbar:
hbar = waitbar(0, 'Processing...')
numsteps = 10;
for i = 1:numstep
waitbar(i/numstep, hbar, sprintf('At step %n', i));
%...
end

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by