0

I'd like to receive an email when Matlab is in debugging mode, so I tried the following:

timerTic=4; % how often the timer checks

timerHandle = timer();
timerHandle.startDelay = timerTic;
timerHandle.Period = timerTic;
timerHandle.ExecutionMode = 'fixedRate';
timerHandle.TasksToExecute = inf;
timerHandle.TimerFcn = @CheckDebugMode;


j=0;
while t==0
    j=j+1;
end

where the funcion is:

function CheckDebugMode( ~ )
% Check if Matlab is in Debug mode
if feature('IsDebugMode')
    sendSSLmail('mymail@mycountry','Matlab is in debug mode','Matlab is in debug mode')
end

t doesn't exist so that an error occurs and Matlab enters in debug mode (dbstop if error is active). feature('IsDebugMode') is equal to 1, but I receive no mail.

It's the first time I work with objects in Matlab, so I'm pretty sure the code is in someway wrong. Maybe someone can help me? Thanks in advance

1 Answers1

0

Do you start your timer?

start(timerHandle)

edit I haven't tested this but I suspect you have problems with your function handle and the function itself. The timer passes arguments to your function, so you need to accept then in your code:

function CheckDebugMode( varargin )

or stop then from being passed:

timerHandle.TimerFcn = @(~,~)CheckDebugMode
matlabgui
  • 5,642
  • 1
  • 12
  • 15
  • Actually not! I started it but then I receive the following error: Error while evaluating TimerFcn for timer 'timer-7' Too many input arguments. timerTic=4; % how often the timer checks timerHandle = timer(); timerHandle.startDelay = timerTic; timerHandle.Period = timerTic; timerHandle.ExecutionMode = 'fixedRate'; timerHandle.TasksToExecute = inf; timerHandle.TimerFcn = @CheckDebugMode; start(timerHandle) j=0; while t==0 j=j+1; end – Daniele F. Nov 25 '16 at 14:36
  • I just added the varargin in the funtion. Thanks a lot for your help, now it works! – Daniele F. Nov 28 '16 at 12:11