Soft interrupting of long computer runs

버전 1.0.0.0 (6.18 KB) 작성자: Miroslav Balda
Long run of the program can be interrupted without any loss of data in a workspace.
다운로드 수: 410
업데이트 날짜: 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