How to make assert() debug break?
Mostrar comentarios más antiguos
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 comentario
Jan
el 5 de Jul. de 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?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Debugging and Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!