Have you ever desparately wished that you could find out what your calculation was up to, but, since it had been running a long time already, you didn't want to interrupt it, especially in case it was close? I have often wanted this. And now, on the Editor portion of the toolstrip, you can do this.
Just to show you what the different states looked like, I have created a horrible piece of code to run.
function a = forever while 1 a = 1+1; end end
As you can see, it would never stop. Before I run it, here's what you see with the editor in focus.
When the code is executing, you see this, again with the editor still in focus.
You are given the opportunity to pause the running code. MATLAB will pop you into the debugger where you can do the usual sleuthing around. And then...
Once you've done what you wanted in the debugger, you can then press Continue or Quit Debugging.
And go happily (I hope) along with your work.
Do you find this new capability useful? We'd love to hear if it helps you out here.
Get the MATLAB code
Published with MATLAB® R2016a
Comments are closed.
11 CommentsOldest to Newest
The feature is great.
Does it have any implications (Like ‘dbstop if error’) on performance?
If it does, any way to say I prefer to disable this feature for the run to gain some performance?
If you don’t use it, it doesn’t affect performance.
Loren, this a great addition to the editor. I run into this desire often. A pause button, especially one that does not affect performance, is long-awaited and much appreciated. Thanks!
The pause feature is great!. I only wish 1.) Mathsoft will get our multiple server license business sorted out soon, because it is an issue which prevents me from using needed toolboxes. 2.) I have been able to run R2016a on myMac pro (late 2013) with OS Mavericks. However, I understand that R2016a isn’t supported on that OS. Or is it that it isn’t supported on a 32 bit version of it? I don’t think so, because I don’t think there is any 32 bit Mac OS Mavericks available. I certainly don’t have one. Sorry, but I’m a bit frustrated as I really like the Live Editor for testing my scripts and documenting them. I enjoy your posts!
@Jonathan – Glad you like it.
@John, I assume you mean MathWorks, as we have nothing to do with MathSoft, including their licenses. You can find the MAC system requirements here: https://www.mathworks.com/support/sysreq/current_release/index.html?sec=mac From that page:
“Note: OS X 10.9 is not supported as of R2016a.”
I understand the frustration. Sorry I can’t help more. I assume you’ve thought about updating your OS?
I think that this is a great thing. I have an assumption about this, but I just wanted to verify my guess. This will only actually pause the code at the end of a line, as opposed to within a builtin? For example, if I make a mistake and end up trying to do an fft on a vector that is say 2^25 elements long, I can’t use this to interrupt the actual fft computation, can I?
It won’t pause inside MATLAB built-ins. Pause can only interrupt in the same places that Ctrl-C can as well.
I don’t understand, could you explain how can it not hurt performance?
It sounds counter logic.
I would guess it would hurt the JIT Optimization badly.
To me, it sounds like “Always Run on Debug Mode”.
Could you please elaborate, it is really interesting.
It’s kind of like a try-catch. Everything runs well until you hit the pause or the catch. At that point, things might slow down, but not really before. To pause or catch, there’s a lot of structure and state that needs to be assembled. But not till you reach that point.
I cannot find this function on OS X. Is there any keyboard command?
@Jerome – What do you mean when you say that you cannot find the function? The Pause button should be available on all platforms since R2016a. As for the keyboard command, it is Ctrl-F5 on Windows and Cmd-F5 on Mac.