Call MATLAB "finish" (aka on exit) code directly
Alec Jacobson
October 02, 2012
I have my matlab finish script set up so that it saves the current workspace and preserves the entire history. This is really useful when I restart matlab. Unfortunately it's only called when I exit matlab in a normal way. If matlab crashes or hangs (and then I have to kill it) then the finish script isn't called and I don't reap the benefits.
Until now I didn't realize the obvious thing to do is to simply issue:
finish
before executing some crashy code.