2016-11-24 81 views
0

我想收到一封电子邮件时,Matlab是在调试模式下,所以我尝试了以下内容:接收邮件,如果MATLAB是在调试模式下

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 

其中funcion是:

function CheckDebugMode(~) 
% Check if Matlab is in Debug mode 
if feature('IsDebugMode') 
    sendSSLmail('[email protected]','Matlab is in debug mode','Matlab is in debug mode') 
end 

t不存在,因此发生错误并且Matlab进入调试模式(如果错误处于活动状态,则为dbstop)。 功能('IsDebugMode')等于1,但我没有收到邮件。

这是我第一次在Matlab中使用对象,所以我敢肯定代码在某种程度上是错误的。 也许有人可以帮助我吗? 在此先感谢

回答

0

您是否开始计时?

start(timerHandle) 

编辑我没有测试过这一点,但我怀疑你有你的功能手柄和功能本身的问题。计时器参数传递给你的函数,所以你需要在你的代码来接受,那么:

function CheckDebugMode(varargin) 

或传递,然后停止:

timerHandle.TimerFcn = @(~,~)CheckDebugMode 
+0

其实都不是! 我开始它,但后来我收到以下错误: 评估定时器'定时器-7'的TimerFcn时出错 输入参数太多。 timerTic = 4; %定时器检查的频率 timerHandle = timer(); timerHandle.startDelay = timerTic; timerHandle.Period = timerTic; timerHandle.ExecutionMode ='fixedRate'; timerHandle.TasksToExecute = inf; timerHandle.TimerFcn = @CheckDebugMode; start(timerHandle) j = 0; 而t == 0 j = j + 1; 结束 –

+0

我刚刚在函数中添加了varargin。非常感谢您的帮助,现在它可以工作! –