MATLAB Answers

Matlab not stopping on some breakpoints

18 views (last 30 days)
Ray Harris
Ray Harris on 1 Jul 2020
Edited: Adam Danz on 1 Jul 2020
Matlab suddenly (this afternoon) stopped honoring some, but not all, of my breakpoints on a file I have been working on since this morning.
I tried reloading Matlab, but problem persisted.
I tried removing my only "clear" statement (I have no "clear all" statements) and it had no effect.
Matlab is useless fo rme until this gets fixed!!!!!

  1 Comment

Adam Danz
Adam Danz on 1 Jul 2020
Have you tried removing all break points, saving the file, closing the file, reopening the file, and setting new break points?
This has never happened to me and I use debug mode with break points on a nearly daily basis for years.

Sign in to comment.

Answers (2)

Gurpreet Singh
Gurpreet Singh on 1 Jul 2020
Hi Ray,
Please refer to the following Doc in MATLAB Command Window:
>>web(fullfile(docroot, 'matlab/debugging-code.html'))
You can also try to use the following command at the beginning of script:
>>dbstop if caught error
MATLAB will go to debug mode at the erroneous line, though this will probably stop more than the user wants.
You can also execute only selected code by keyboard shortcut F9.


Sign in to comment.

Image Analyst
Image Analyst on 1 Jul 2020
Yes, it can happen and I see it fairly often. It's usually when I do something like set breakpoints and run then stop at a breakpoint. Then change a variable name or edit the code somehow and set new breakpoint. Then it sometimes won't stop at the new breakpoints, I think because the file needs to be saved again. If I just exit and restart, then it will see the new breakpoints and stop at them.

  1 Comment

Adam Danz
Adam Danz on 1 Jul 2020
Breakpoints that are added while running debug mode after editing the file are invalid. This has always been the case. In the first image below, the breakpoint is red. In the second image below, I added a comment while paused in bebug mode and then added a second breakpoint. Both breakspoints turn gray and the new breakpoint will be ignored until the file is saved which can only be done outside of debug mode. All existing breakpoints prior to editing will be valid but breakpoints added after editing the file while in debug mode will be ignored.
Another cause of invalid breakpoints is when there is a syntax error within the file.
This is explained here in the documentation under "invalid breakpoints".

Sign in to comment.




Translated by