Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!newsfeed.fsmpi.rwth-aachen.de!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: try catch /ctrl-c behaviour
Date: Fri, 05 Apr 2013 04:49:07 -0500
Organization: Aioe.org NNTP Server
Lines: 20
Message-ID: <kjm6mi$tn5$1@speranza.aioe.org>
References: <gC2vc.9$ri2.2@charlie.risq.qc.ca> <_D3vc.12$ri2.0@charlie.risq.qc.ca> <c9iknk$s3g$1@fred.mathworks.com> <kjm5dk$s0v$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: 4d17sIignR0WNtX0j94MLg.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:792730

On 4/5/2013 4:27 AM, Peeyush wrote:

>
>   Continuing in the same vein, what if I want to stop the execution
>of a long loop before it's termination condition? and I still want to carry
>out some processing on a partially analyzed dataset? Currently, ctrl-c breaks
>the loop and I lose the intermediate results....
>
> I'm running Matlab 12 on a Mac.
>

You have to add your own logic. For example, Make a button and
in the callback set a flag that the main loop checks on at the
end of each iteration. When the main loop detects this flag is set to
terminate, then it can cleanly terminate and do any other
intermediate  work.

--Nasser