Loren on the Art of MATLAB

Turn ideas into MATLAB

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Pausing for a Favorite Feature of R2016a 11

Posted by Loren Shure,

You may end up hearing this from many of the different bloggers at MathWorks. Steve and Stuart did! And now for my turn.


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.

Example Code

Just to show you what the different states looked like, I have created a horrible piece of code to run.

type forever
function a = forever
while 1
    a = 1+1;

Before You Start

As you can see, it would never stop. Before I run it, here's what you see with the editor in focus.

Once the Code is Running

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...

Continue Executing the Code

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

Royi replied on : 1 of 11

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?

Thank You.

Jonathan replied on : 3 of 11

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!

John Ondov replied on : 4 of 11

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!

Loren Shure replied on : 5 of 11

@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?


Dan replied on : 6 of 11

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?


Loren Shure replied on : 7 of 11


It won’t pause inside MATLAB built-ins. Pause can only interrupt in the same places that Ctrl-C can as well.


Royi replied on : 8 of 11

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.

Loren Shure replied on : 9 of 11


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.


Christian Weigandt replied on : 11 of 11

@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.