Keyboard replacement with stack trace
The 'keyboard' command is great for debugging, but if you have multiple instances of keyboard, it is very difficult to tell which one is being called. This complicates debugging somewhat.
kdb() is a drop-in replacement for keyboard, and it shows a stack trace, preview of the next line to be executed, and a hyperlink to that line of code. For example, if foo() calls bar() calls baz() and we have a 'keyboard' command in baz(), the user sees
>> foo
K>>
whereas with kdb() the user sees
>> foo
baz:2 << bar:2 << foo:3
3 y = x+2;
K>>
The '3' is a hyperlink to line 3 of baz.m, and depending on settings the Matlab editor may automatically open to the appropriate kdb() statement. The only caveat is that unlike keyboard, kdb() cannot be the last statement in the function.
Citation pour cette source
Romesh (2026). Keyboard replacement with stack trace (https://fr.mathworks.com/matlabcentral/fileexchange/40415-keyboard-replacement-with-stack-trace), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
- MATLAB > Environment and Settings > Desktop >
- MATLAB > Software Development Tools > Debugging and Analysis >
Tags
Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
| Version | Publié le | Notes de version | |
|---|---|---|---|
| 1.1.0.0 | Updated with suggestions from Per Isakson to support packages |
||
| 1.0.0.0 |
