How can I have a timer continue after an error?
2 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Sean de Wolski
on 1 Oct 2015
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
on 1 Oct 2015
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 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!