dbstopif(condition)
When working with long loops of processing one may need to set a breakpoint to stop on a particular condition. While Matlab's built in conditional breakpoints achieve this, they exact a heavy performance penalty (even when disabled!), and are not generally maintained between sessions. dbstopif is inserted as a single line of code which which, if the condition is true, sets a regular breakpoint on the following line, resulting in an immediate dbstop.
A comparison of the time to execute a loop with many iterations:
Matlab conditional breakpoint enabled: Elapsed time is 34.412000 seconds.
dbstopif: Elapsed time is 0.004994 seconds.
Disabled:
Matlab conditional breakpoint disabled: Elapsed time is 51.132263 seconds.
dbstopif: Elapsed time is 0.004941 seconds.
Matlab conditional breakpoint removed: Elapsed time is 0.004422 seconds.
dbstopif: Elapsed time is 0.004628 seconds.
Cite As
Dan K. (2024). dbstopif(condition) (https://www.mathworks.com/matlabcentral/fileexchange/62969-dbstopif-condition), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |