Pausing a for loop execution

1 次查看(过去 30 天)
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.

采纳的回答

Dr. Seis
Dr. Seis 2011-11-10
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by