Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to stop a program running

Subject: How to stop a program running

From: Diego Zegarra

Date: 23 Feb, 2009 00:04:02

Message: 1 of 4

Hi guys,

If I am running a .m file, is there anyway I can pause it whenever I want? I know that when you are debugging you can just put a break point and it will always stop there, thats the thing, I want to stop it when I want to, not at every iteration.

Thanks!

Subject: How to stop a program running

From: Walter Roberson

Date: 23 Feb, 2009 00:24:55

Message: 2 of 4

Diego Zegarra wrote:

> If I am running a .m file, is there anyway I can pause it whenever I want?

Sorry, no, there is not. The core matlab routines omit checks for potential
interruptions for performance reasons, so it is not possible to check
at completely arbitrary times. Depending on what is being done, it can take
seconds or minutes or even hours before Matlab is ready to check to see
if something else should be done.

>I know that when you are debugging you can just put a break point and it will always stop
>there, thats the thing, I want to stop it when I want to, not at every iteration.

Would a conditional breakpoint be a possible solution? e.g., one way
of doing it would be to define a global variable, and have a uicontrol
which sets the global variable non-zero when you click it; the
conditional breakpoint could then be checking to see whether the global
was non-zero.

Subject: How to stop a program running

From: Diego Zegarra

Date: 23 Feb, 2009 00:37:01

Message: 3 of 4

Walter,

Thanks for your response. Could you please explain me more how that could work?

Subject: How to stop a program running

From: Steven Lord

Date: 23 Feb, 2009 15:22:55

Message: 4 of 4


"Walter Roberson" <roberson@hushmail.com> wrote in message
news:R0mol.15634$i42.10835@newsfe17.iad...
> Diego Zegarra wrote:
>
>> If I am running a .m file, is there anyway I can pause it whenever I
>> want?
>
> Sorry, no, there is not. The core matlab routines omit checks for
> potential
> interruptions for performance reasons, so it is not possible to check
> at completely arbitrary times. Depending on what is being done, it can
> take
> seconds or minutes or even hours before Matlab is ready to check to see
> if something else should be done.
>
>>I know that when you are debugging you can just put a break point and it
>>will always stop
>>there, thats the thing, I want to stop it when I want to, not at every
>>iteration.
>
> Would a conditional breakpoint be a possible solution? e.g., one way
> of doing it would be to define a global variable, and have a uicontrol
> which sets the global variable non-zero when you click it; the
> conditional breakpoint could then be checking to see whether the global
> was non-zero.

A conditional breakpoint is one way to do this. Another way, if you know
the conditions under which you want it to stop ahead of time, and you always
want to stop at a particular location if the conditions are satisfied, is to
insert an IF statement that checks the condition at that location and use
the KEYBOARD statement inside the IF block. This does require a code change
(unlike conditional breakpoints) but unlike breakpoints, the KEYBOARD
statement isn't removed by CLEAR.

--
Steve Lord
slord@mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us