Pausing a for loop execution

1 Ansicht (letzte 30 Tage)
Michael Joslin
Michael Joslin am 10 Nov. 2011
I have the following section of code:
%%%%%%Loop through signals
for idx = 1:length(missing_sigs)
mis_sig_no_tok = strtok(missing_sigs{idx},'>');
mis_sig_no_tok = strtok(mis_sig_no_tok,'<');
ResolveMissingSigs(mis_sig_no_tok);
end
ResolveMissingSigs is a function that makes a gui appear with options for the user to choose how they want to deal with the missing signal. The problem is that the current code calls the gui function but the loop causes only the last signal to be seen. I want the loop to pause every time ResolveMissingSigs is called and resume execution to the next signal after the user has made their choice.

Akzeptierte Antwort

Dr. Seis
Dr. Seis am 10 Nov. 2011
Check out "doc uiwait". Basically, you will just change the above to:
for idx = 1:length(missing_sigs)
mis_sig_no_tok = strtok(missing_sigs{idx},'>');
mis_sig_no_tok = strtok(mis_sig_no_tok,'<');
gui_handle = ResolveMissingSigs(mis_sig_no_tok);
uiwait(gui_handle);
end
The loop will continue as soon as you close/exit your GUI. You can also have the loop continue after a set amount of time. For example:
uiwait(gui_handle, 10);
will allow the loop to continue if you close/exit the GUI or after 10 seconds.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by