I also needed an answer to this question! I was pleased just now to find here on Answers that feature('IsDebugMode') does the trick. Before turning to Answers I was looking in the MATLAB help, and came up with this alternative:
isDebugMode = true;
isDebugMode = false;
Although the undocumented feature() is much neater, this is an alternative if you want to stay on official MATLAB.