Code covered by the BSD License  

Highlights from
Pause a long MATLAB run with a simple click.

5.0

5.0 | 2 ratings Rate this file 55 Downloads (last 30 days) File Size: 1.51 KB File ID: #35114
image thumbnail

Pause a long MATLAB run with a simple click.

by

 

16 Feb 2012 (Updated )

A simple way to pause a long simulation, to check progress, without expensive breakpoints or checks

| Watch this File

File Information
Description

Sometimes you create MATLAB functions that take ages to run (more than 10 minutes). You want to be able to pause every now and then, by clicking a "CTRL+P" or something like that, make sure all the values are ok, and then continue running from the same spot. If you tried "CTRL+C", you know it's not working well. So, untill such an option will exist, I wrote a simple example to show how you can use a PushButton and a guarded breakpoint to do so.
Run the file, by executing "myFunc(1)".
You will see a button pop up. Every time you press it, it will halt the function's execution and allow you to view the progress of the code.
Pressing F5 will continue the run.

You can use this as a template for your specific needs, simply modify and use.

Acknowledgements

This file inspired Soft Interrupting Of Long Computer Runs.

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
29 May 2014 Stefano

Really useful! Thanks!
The last lines of myFcn(u) should actually be:

close(h)
clear h

So that the "pause" plot window is closed and h is released.

22 Feb 2013 Seban

Works like a charm :)

21 Feb 2012 Roni Peer

Good suggestion, Jan. I've modified the files so they reflect this.
Thanks!

20 Feb 2012 Jan Simon

What about calling KEYBOARD in the callback of the button? Then there is no need for a GLOBAL variable or setting a breakpoint. See "help keyboard".

Updates
21 Feb 2012

Removed unnecessary FLAG checks.

Contact us