How can I have a timer continue after an error?
2 次查看(过去 30 天)
显示 更早的评论
Here is script A:
t = timer;
t.Period = 10;
t.TasksToExecute = inf;
t.ExecutionMode = 'fixedRate';
t.TimerFcn = 'Weeklys';
start(t)
On occasion I get an error saying
Error while evaluating TimerFcn for timer 'timer-2'
Matrix dimensions must agree.
And then the timer stops running the 'Weeklys' script. Is there a way to have it continue even if it encounters an error?
0 个评论
回答(2 个)
Sean de Wolski
2015-10-1
Far and away, your best bet is to fix the error :). Check if the matrix dimensions agree and if they do not, take a different code path.
Alternatively, put a try/catch block around the 'TimerFcn'
Jan
2015-10-1
Please post the complete error message.
t.TimerFcn = 'Weeklys';
Try to use a function handle as TimerFcn as explained in the documentation of timer.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!