Soft interrupting of long computer runs

版本 1.0.0.0 (6.2 KB) 作者: Miroslav Balda
Long run of the program can be interrupted without any loss of data in a workspace.
410.0 次下载
更新时间 2012/2/25

查看许可证

Solutions of iterative tasks take sometimes much longer time than expected. There are two possibilities how to solve the issue, either to wait until the program finishes the task, or to interrupt the computer run. Both alternatives are unpleasant.

In the first case, there is rather high uncertainty either how much time the computation could take, or whether it has entered an infinite loop. In the second case, not always it is possible to stop the run by pushing Ctrl+C. Then, the system task manager should be started and the whole MATLAB be suspended. Both alternatives are painful.

There are several functions in FEX that enable to escape from cycling of a program. This contribution is yet another one, based on Roni Peer's contribution (http://www.mathworks.com/matlabcentral/fileexchange/35114).

The submitted contribution contains:
- demo file test.m as a sample of real program structure,
- function setbutton.m for creating BREAK button figure window, and
- function iterpt.m.
All modules are interconnected via global variable FLAG.

The function setbutton.m should be called outside a cycle before iterations or critical cycle starts. It creates a small figure window with a button BREAK on the user defined place of screen.

The function interpt should be inserted in a critical place of iterations. Normally, it is passed through without any slowing down. However, as soon as the function interpt be entered after the BREAK button be pushed, the execution is caught in the function, names of transfered variables are displayed and the program enters the keyboard mode. The user may enter any command from the keyboard. He can display values of the variables either step by step, or, if they were of the same kind in one go by the command disp([varargin{:}]).

The keyboard mode can be interrupted by pushing the function key F5.
The prompt "CONTINUE = yes => " is dispayed and the user decides whether to accept the offer by pushing the ENTER key and continue, or make a hard interrupt by pushing any other key followed by ENTER. In both case the program returns from the function interpt back, where the user can decide what to do. Normally, he tests the global variable FLAG , and suspends the program by a cycle break. Alternatively, he can change iteration conditions and continue in looping.

In both case, the MATLAB environment remains alive with all variables in the workspace.

引用格式

Miroslav Balda (2024). Soft interrupting of long computer runs (https://www.mathworks.com/matlabcentral/fileexchange/35323-soft-interrupting-of-long-computer-runs), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2006b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Desktop 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0