"Nasser M. Abbasi" <firstname.lastname@example.org> wrote in message news:email@example.com... > 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.
Having your program create an onCleanup object that saves the workspace as its cleanup function before entering the loop is another possibility.