MATLAB: Dbstop if error stops in “drawnow”

dbstopdrawnow

Dear Community,
I'm facing a rather odd problem and want to know if someone experienced a similar problem, or even knows a solution.
I usually have
dbstop if error
enabled. In a script that prints png-files with bargraphs the debugger stops in
36 drawnow; % give changes a chance to be processed
The Function Call Stack is: Base * myscript * print alternatePrintPath
Quit Debugging or Continue often results in another stop after 5-10 seconds of processing.
My script does nothing fancy, the only "unusual" thing in my mind might be that the struct from which the pngs are plotted is over 1 GB in size. The break by the debugger is not labeled as an error just as shown above as "36 drawnow …" in the internal print.m
Without "dbstop if error" the script just runs fine.

Best Answer

drawnow stops with an error, if a graphic object has been created, which cannot be displayed correctly, e.g. a listbox with the 'Value' set higher than the number of elements. Or a slider with the value outside the defined range. Or A listbox with a single selection activated, but the value is empty.
Then updating the graphics fail "inside" drawnow. But you should get a corresponding error message directly. But you do not mention any message, but only the calling stack.
What does "results in another stop after 5-10 seconds" exactly mean? Where does it stop?
What does "The break by the debugger is not labeled as an error" mean and what is the "internal print.m"?
You wrote that you "usually" run your code with the enabled dbstop. Are you aware that Matlab's JIT accelerator is disabled then? Some loops might be up to 100 times faster without enabled debugger.
Can you post a piece of code, which reproduces the error? Currently the problem looks really strange and magic, but this means usually, that something trivial happens that the programmer is not aware of. Without seeing the code, it is hard to guess such details.