Code covered by the BSD License  

Highlights from
Soft interrupting of long computer runs

Be the first to rate this file! 20 Downloads (last 30 days) File Size: 6.18 KB File ID: #35323

Soft interrupting of long computer runs

by

 

Long run of the program can be interrupted without any loss of data in a workspace.

| Watch this File

File Information
Description

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.

Acknowledgements

Pause A Long Matlab Run With A Simple Click. inspired this file.

MATLAB release MATLAB 7.3 (R2006b)
Other requirements The FEX function inp.m (www.mathworks.com/matlabcentral/fileexchange/9033)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us