<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447</link>
    <title>MATLAB Central Newsreader - how to stop execution</title>
    <description>Feed for thread: how to stop execution</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 11 Mar 2009 21:03:00 -0400</pubDate>
      <title>how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#634163</link>
      <author>Todd Welti</author>
      <description>This might seem like a dumb question, but how do you stop code execution?  I dont mean 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no fanfare and just return to the command line.  Strangley enough, i can't seem to find a command that does this!  &quot;Return&quot; doesn't necessarily work if the current function is not the main function. &quot;dbstop&quot; puts it in debug mode.  &quot;quit&quot; quits matlab.&lt;br&gt;
&lt;br&gt;
I've looked and looked and can't find this simple command.</description>
    </item>
    <item>
      <pubDate>Wed, 11 Mar 2009 21:44:29 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#634171</link>
      <author>Walter Roberson</author>
      <description>Todd Welti wrote:&lt;br&gt;
&amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean&lt;br&gt;
&amp;gt; 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no&lt;br&gt;
&amp;gt; fanfare and just return to the command line.&lt;br&gt;
&lt;br&gt;
There isn't a way: all of those routines have to be unwound and their workspaces&lt;br&gt;
cleaned up, which might invoke exit handlers, and so on.&lt;br&gt;
&lt;br&gt;
The closest I can think of is to have your main routine have a try/catch&lt;br&gt;
and then when you wish to abort, error() the particular string that the&lt;br&gt;
catch is keyed for, and when you detect it, bail out cleanly from your&lt;br&gt;
main routine.</description>
    </item>
    <item>
      <pubDate>Wed, 11 Mar 2009 22:05:05 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#634176</link>
      <author>Matt Fig</author>
      <description>ctrl+c</description>
    </item>
    <item>
      <pubDate>Wed, 11 Mar 2009 23:50:21 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#634190</link>
      <author>Todd Welti</author>
      <description>&quot;Matt Fig&quot; &amp;lt;spamanon@yahoo.com&amp;gt; wrote in message &amp;lt;gp9cig$lul$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; ctrl+c&lt;br&gt;
&lt;br&gt;
I meant a command that would be in the code.</description>
    </item>
    <item>
      <pubDate>Wed, 11 Mar 2009 23:52:02 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#634191</link>
      <author>Todd Welti</author>
      <description>Walter Roberson &amp;lt;roberson@hushmail.com&amp;gt; wrote in message &amp;lt;XgWtl.34251$l71.6225@newsfe23.iad&amp;gt;...&lt;br&gt;
&amp;gt; Todd Welti wrote:&lt;br&gt;
&amp;gt; &amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean&lt;br&gt;
&amp;gt; &amp;gt; 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no&lt;br&gt;
&amp;gt; &amp;gt; fanfare and just return to the command line.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; There isn't a way: all of those routines have to be unwound and their workspaces&lt;br&gt;
&amp;gt; cleaned up, which might invoke exit handlers, and so on.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The closest I can think of is to have your main routine have a try/catch&lt;br&gt;
&amp;gt; and then when you wish to abort, error() the particular string that the&lt;br&gt;
&amp;gt; catch is keyed for, and when you detect it, bail out cleanly from your&lt;br&gt;
&amp;gt; main routine.&lt;br&gt;
&lt;br&gt;
Yes, that should work.  is it just me or is it strange that there is not such a command - like ctrl c, but useable in an mfile?</description>
    </item>
    <item>
      <pubDate>Thu, 12 Mar 2009 07:54:04 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#634250</link>
      <author>Jos </author>
      <description>&quot;Todd Welti&quot; &amp;lt;twelti@harman.com&amp;gt; wrote in message &amp;lt;gp9ir2$kcf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Walter Roberson &amp;lt;roberson@hushmail.com&amp;gt; wrote in message &amp;lt;XgWtl.34251$l71.6225@newsfe23.iad&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Todd Welti wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; fanfare and just return to the command line.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; There isn't a way: all of those routines have to be unwound and their workspaces&lt;br&gt;
&amp;gt; &amp;gt; cleaned up, which might invoke exit handlers, and so on.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The closest I can think of is to have your main routine have a try/catch&lt;br&gt;
&amp;gt; &amp;gt; and then when you wish to abort, error() the particular string that the&lt;br&gt;
&amp;gt; &amp;gt; catch is keyed for, and when you detect it, bail out cleanly from your&lt;br&gt;
&amp;gt; &amp;gt; main routine.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes, that should work.  is it just me or is it strange that there is not such a command - like ctrl c, but useable in an mfile?&lt;br&gt;
&lt;br&gt;
help keyboard&lt;br&gt;
&lt;br&gt;
(or modify finish.m and use quit cancel)&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Jos</description>
    </item>
    <item>
      <pubDate>Wed, 31 Mar 2010 18:27:07 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#731932</link>
      <author>Peter O'Connor</author>
      <description>Here's what I use to do that (a little roundabout because, ridiculously, it requires that the user confirm that you'd like to quit)&lt;br&gt;
&lt;br&gt;
disp('You chose to cancel.  Quit the program now?');&lt;br&gt;
disp('&amp;lt;a href=&quot;MATLAB: dbquit;&quot;&amp;gt;Yes&amp;lt;/a&amp;gt; / &amp;lt;a href=&quot;MATLAB: dbcont;&quot;&amp;gt;No&amp;lt;/a&amp;gt;');&lt;br&gt;
keyboard;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Jos &quot; &amp;lt;#10584@fileexchange.com&amp;gt; wrote in message &amp;lt;gpaf2s$hc1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Todd Welti&quot; &amp;lt;twelti@harman.com&amp;gt; wrote in message &amp;lt;gp9ir2$kcf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Walter Roberson &amp;lt;roberson@hushmail.com&amp;gt; wrote in message &amp;lt;XgWtl.34251$l71.6225@newsfe23.iad&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Todd Welti wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; fanfare and just return to the command line.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; There isn't a way: all of those routines have to be unwound and their workspaces&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; cleaned up, which might invoke exit handlers, and so on.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The closest I can think of is to have your main routine have a try/catch&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; and then when you wish to abort, error() the particular string that the&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; catch is keyed for, and when you detect it, bail out cleanly from your&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; main routine.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Yes, that should work.  is it just me or is it strange that there is not such a command - like ctrl c, but useable in an mfile?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; help keyboard&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; (or modify finish.m and use quit cancel)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; hth&lt;br&gt;
&amp;gt; Jos</description>
    </item>
    <item>
      <pubDate>Wed, 31 Mar 2010 19:02:20 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#731952</link>
      <author>Todd Welti</author>
      <description>&quot;Peter O'Connor&quot; &amp;lt;peter.oconnor@mail.mcgill.ca&amp;gt; wrote in message &amp;lt;hp045r$h0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Here's what I use to do that (a little roundabout because, ridiculously, it requires that the user confirm that you'd like to quit)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; disp('You chose to cancel.  Quit the program now?');&lt;br&gt;
&amp;gt; disp('&amp;lt;a href=&quot;MATLAB: dbquit;&quot;&amp;gt;Yes&amp;lt;/a&amp;gt; / &amp;lt;a href=&quot;MATLAB: dbcont;&quot;&amp;gt;No&amp;lt;/a&amp;gt;');&lt;br&gt;
&amp;gt; keyboard;&lt;br&gt;
&amp;gt; &lt;br&gt;
Yes, that is slightly easier than using keyboard, then having the user type dbquit, but still not very clean.  Plus I get a web browser opened up when I tried it.  Not sure what would happen for compiled code. &lt;br&gt;
&lt;br&gt;
Looking back in this thread (and one other on tis subject) I see several suggestions to use try/catch.  That's fine if your not in a subfunction or subsubfunction.  The last time I had this problem, not only was I in a sub sub funciton, but complicated by the fact that it was called from a GUI callback anonymous funciton.  I suppose you could have each subfunction returning a success/failed (0 or 1) as is often done anyway.  Then bailing out of a subsub function would result in clean bail out of main.</description>
    </item>
    <item>
      <pubDate>Wed, 31 Mar 2010 19:47:45 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#731966</link>
      <author>Walter Roberson</author>
      <description>Peter O'Connor wrote:&lt;br&gt;
&amp;gt; Here's what I use to do that (a little roundabout because, ridiculously, &lt;br&gt;
&amp;gt; it requires that the user confirm that you'd like to quit)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; disp('You chose to cancel.  Quit the program now?');&lt;br&gt;
&amp;gt; disp('&amp;lt;a href=&quot;MATLAB: dbquit;&quot;&amp;gt;Yes&amp;lt;/a&amp;gt; / &amp;lt;a href=&quot;MATLAB: &lt;br&gt;
&amp;gt; dbcont;&quot;&amp;gt;No&amp;lt;/a&amp;gt;');&lt;br&gt;
&amp;gt; keyboard;&lt;br&gt;
&lt;br&gt;
Testing in 2008b, I found that I had to use lower-case for that matlab. Also, &lt;br&gt;
the space after the colon was not required but was accepted.&lt;br&gt;
&lt;br&gt;
disp('&amp;lt;a href=&quot;matlab:dbquit;&quot;&amp;gt;Yes&amp;lt;/a&amp;gt; / &amp;lt;a href=&quot;matlab:dbcont;&quot;&amp;gt;No&amp;lt;/a&amp;gt;');&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
When I used MATLAB: then the help browser would complain that matlab was &lt;br&gt;
unable to link to the document.</description>
    </item>
    <item>
      <pubDate>Sat, 29 Oct 2011 02:18:15 -0400</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#856657</link>
      <author>Mike Hoff</author>
      <description>&quot;Todd Welti&quot; &amp;lt;twelti@harman.com&amp;gt; wrote in message &amp;lt;gp98u4$g9h$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no fanfare and just return to the command line.  Strangley enough, i can't seem to find a command that does this!  &quot;Return&quot; doesn't necessarily work if the current function is not the main function. &quot;dbstop&quot; puts it in debug mode.  &quot;quit&quot; quits matlab.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I've looked and looked and can't find this simple command.&lt;br&gt;
&lt;br&gt;
I'm going to use&lt;br&gt;
&lt;br&gt;
error('I don't want to play anymore')&lt;br&gt;
&lt;br&gt;
It's quick and dirty, with red and errors and beeping, but it's better than a fancy loop, or commenting everything out</description>
    </item>
    <item>
      <pubDate>Sat, 28 Jan 2012 21:45:11 -0500</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#865095</link>
      <author>Radek </author>
      <description>&quot;Todd Welti&quot; &amp;lt;twelti@harman.com&amp;gt; wrote in message &amp;lt;gp98u4$g9h$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no fanfare and just return to the command line.  Strangley enough, i can't seem to find a command that does this!  &quot;Return&quot; doesn't necessarily work if the current function is not the main function. &quot;dbstop&quot; puts it in debug mode.  &quot;quit&quot; quits matlab.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I've looked and looked and can't find this simple command.&lt;br&gt;
&lt;br&gt;
command:&lt;br&gt;
break </description>
    </item>
    <item>
      <pubDate>Mon, 30 Jan 2012 21:17:11 -0500</pubDate>
      <title>Re: how to stop execution</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246447#865255</link>
      <author>Todd Welti</author>
      <description>&quot;Radek &quot; &amp;lt;dzidmail@gmail.com&amp;gt; wrote in message &amp;lt;jg1q97$gv7$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Todd Welti&quot; &amp;lt;twelti@harman.com&amp;gt; wrote in message &amp;lt;gp98u4$g9h$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; This might seem like a dumb question, but how do you stop code execution?  I dont mean 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no fanfare and just return to the command line.  Strangley enough, i can't seem to find a command that does this!  &quot;Return&quot; doesn't necessarily work if the current function is not the main function. &quot;dbstop&quot; puts it in debug mode.  &quot;quit&quot; quits matlab.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I've looked and looked and can't find this simple command.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; command:&lt;br&gt;
&amp;gt; break &lt;br&gt;
&lt;br&gt;
do you know what the break command does?!?!?  This would not work at all.&lt;br&gt;
&lt;br&gt;
BREAK Terminate execution of WHILE or FOR loop.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BREAK terminates the execution of FOR and WHILE loops.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In nested loops, BREAK exits from the innermost loop only.&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BREAK is not defined outside of a FOR or WHILE loop.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Use RETURN in this context instead.</description>
    </item>
  </channel>
</rss>

