Stopping a paused script

97 views (last 30 days)
Jonathan deWerd
Jonathan deWerd on 20 Nov 2014
Answered: Sean de Wolski on 20 Nov 2014
I recently learned about the "pause" command from a friend. I was quite excited to try it out; being able to press (or hold!) a button to rapidly step through a for loop while plotting internal state at every step sounds like a killer workflow and a huge improvement over repeatedly pressing the "continue" button in the debugger (slow!) or adjusting the upper bound of the loop to look at successive snapshots of its internal state (slower!).
However, I frequently find myself in the position of wanting to break out of a paused loop before the loop is complete (it takes 10 minutes to perform all of the timesteps in my current script). Ctrl+C does not work and I cannot find any option in the GUI to halt execution of the script. I know that Ctrl+C cannot be expected to stop every possible computation because responding to Ctrl+C involves checking an event queue, but if there is one command I would expect to do this it would be "pause" and the fact that "pause" does not obey Ctrl+C completely kills its value proposition to my workflow.
Am I missing something? Is there an alternative way of stopping a script? Is this just a bug in the Mac OS X matlab front-end? Is there an alternative command similar to "pause" that does check its event queue and obey Ctrl+C?
Thanks in advance, Jon
Steps to reproduce:
  • Type "pause" into the matlab command line (Mac OS X, MATLAB_R2014A)
  • Note that Ctrl+C does not break the "pause" command
  2 Comments
Geoff Hayes
Geoff Hayes on 20 Nov 2014
Jonathan - maybe I'm missing something, but pressing ctrl+c does break (for me) the pause. I am running R2014a on OS X 10.8.5. You do mean control and not command, correct?
Andrew Reibold
Andrew Reibold on 20 Nov 2014
I typed pause(5) in my command line (2014a), and when I hit Ctrl+C it broke it early...

Sign in to comment.

Answers (1)

Sean de Wolski
Sean de Wolski on 20 Nov 2014
I would suggest a different approach.
Rather than using a pause, put a break point on the line you want to pause on. Then you can press "Continue" to run the next iteration and when you're happy and want to cease further execution, press "Quit Debugging" to stop like you want. Then once, you're happy all around, rather than having to remove or comment the pause, you just disable the break point.

Categories

Find more on Graphics Objects in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!