How to make assert() debug break?
Afficher commentaires plus anciens
I attached my solution. Not sure why it's not the default behavior.
function assert1( b )
if nargin < 1
b = 0;
end
if ~b
disp( 'Assertion failed.' );
dbstack
if 0
dbstop in assert.m at 11;
dbclear in assert.m at 11;
else
ST = dbstack;
if length( ST ) > 1
ST = ST(2);
end
fl = ST.file;
ln = ST.line + 1;
cmd = [ 'dbstop in ' fl ' at ' int2str(ln) ];
eval( cmd )
end
end
end
1 commentaire
Jan
le 5 Juil 2022
What is the behavior of your code? It creates a breakpoint in the next line and Matlab will stop there.
What happens in nested functions, functions attached to a script and in anonymous functions?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Debugging and Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!