Pausing a for loop execution

8 ビュー (過去 30 日間)
Michael Joslin
Michael Joslin 2011 年 11 月 10 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by