From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: try catch /ctrl-c behaviour
Date: Fri, 05 Apr 2013 04:49:07 -0500
Organization: NNTP Server
Lines: 20
Message-ID: <kjm6mi$tn5$>
References: <gC2vc.9$> <_D3vc.12$> <c9iknk$s3g$> <kjm5dk$s0v$>
Reply-To: <HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
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: 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.