Matlab after enter Ctrl+c, Can we execute some code or calling a function? -
sometimes, matlab code may run long time. want stop - enter ctrl+c, want execute code after that. e.g.
for = 1:100000, m(i) = function(i,values); end
even if loop not over, stop ctr+c or abnormal situation etc. want call function other process.
n = new_func(m) save(n)
take in oncleanup
object. create oncleanup
object giving code you'd run when code finishes - , whether code finishes naturally, error, or ctrl-c.
there's small restriction on use - needs used within function, not script (because executes code when oncleanup
object goes out of scope , deleted, rather when code ends). that's not of restriction.
Comments
Post a Comment