0

If I press Ctrl + C during the execution of a long loop, I lose all the work that has done so far. So is there a way in MATLAB that I can press Ctrl + C, but return the current variables?

so what I want as a pseudo-code :

for i=1:very_long
 do_things();
 if keypress(ctrlc_orsomeothercombo)
  disp('Im bored!');
  return;
 end
end

Is this possible?

Thanks

jeff
  • 13,055
  • 29
  • 78
  • 136

1 Answers1

3

If you turn stop on errors on, then interrupting it, even with ctrl+c, brings you to the place where it was executing and you have the whole workspace available:

dbstop if error
A Hernandez
  • 484
  • 2
  • 7