debugging - Matlab custom dbstop handler -
i know people have discussed how make custom dbstop
conditions, (such in customize dbstop in matlab)
however, using normal dbstop if error
, want know (from process) whether matlab process in debugging state (k>>
) or running.
i if had custom dbstop
handler function. still want able hands-on debugging normal dbstop if error
.
if there other possibilities detect state of matlab outside (>>
vs k>>
), happy!
let me know idea ;)
timers in matlab can spawn seperate thread wait in can around problem of needing outside current matlab instance. can set timer check if debug mode active , if something.
a example function check if debug mode active , if something:
function mycallbackfunction(~,~) if feature('isdebugmode') % undocumented catzlovejazz load handel sound(y,fs)
the 2 previous lines attention grabbing example, other possibilities use beep
, write file, or run commands or function.
evalin('base','stop(timerhandle)') % stop timer end end
this function modified evaluate 'attention grab' once , reset once debug mode no longer active. relies on stopping , manually restarting timer.
(note: previous version had else redundant not run while workspace busy)
now create timer object.
timertic=4; % how timer checks timerhandle = timer(); timerhandle.startdelay = timertic; timerhandle.period = timertic; timerhandle.executionmode = 'fixedrate'; timerhandle.taskstoexecute = inf; timerhandle.timerfcn = @mycallbackfunction;
and start timer call
start(timerhandle)
the timer automatically stop after running attention grabbing lines. if debug mode never entered timer keep running , need stoped manually stop(timerhandle)
remember run delete(timerhandle)
once finished remove object before clearing timerhandle
variable
Comments
Post a Comment