Inject error in function
This function (most likely) generates an error at an arbitrary line in a function. The taken approach may be used to solve the long-standing problem of breaking out of a function using a callback, without the need to modify the function in question.
It does this by quite brutal means: Namely, it injects ( via the use of dbstop ) at every line the command `clear all`.
Cite As
tommsch (2025). Inject error in function (https://www.mathworks.com/matlabcentral/fileexchange/83283-inject-error-in-function), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired by: tracer4m
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.