Tags: ctrl-break, display, involves, iteration, iterations, key, magic, matlab, michael, number, program, programming, verbose, wrotegtgt

Magic Key wanted! how to ctrl-break the

On Programmer » Matlab

1,843 words with 0 Comments; publish: Wed, 07 May 2008 21:53:00 GMT; (20046.88, « »)

Michael wrote:


> HI all,

> My program involves large number of iterations.

> 1. I found out when I display each iteration in verbose mode(that's

> to say,

> choose an option to let the program display some values along with

> each

> iteration, so that I could monitor the progress better),

> I can break the execution of the program at any time using Ctrl-C,

> or

> Ctrl-Break, (although the response was very slow and delayed -- at

> least it

> stopped as I wanted).

> 2. However, when I switch off the option for it to display

> iterations(i.e.

> no progress is printed to the Matlab console, I did this for the

> sake of

> speed, I understand that printing each iteration to the console

> slows down

> the program), it no longer respond to any of my Ctrl-C and

> Ctrl-Break.

> My program is, virtually, dead.

> 3. I also found that a program can never be stopped if there is

> "while"

> loop.

> Is there a way to break the execution of the program at any time,

> even

> within a "while" loop?

> Any magic keys that can stop the program unconditionally and

> fastly?

> Thanks a lot!


I don't think there is a magic key with Matlab on Windows. However,

ctrl-C works if you put a line in the loop that ... . Somebody who

knows more about OS-calls might fill in. Try the function, CntrC.

Note that the command window must be in focus (be active) when you

issue cntr-C. A problem is that this extra line takes some time.

"fprintf('')," is the fastest I found.

function CntrlC

while true


fprintf(''), % or pause or drawnow



/ per

All Comments

Leave a comment...