How can I have a timer continue after an error?

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?

Antworten (2)

Sean de Wolski
Sean de Wolski am 1 Okt. 2015

0 Stimmen

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'

1 Kommentar

Cary
Cary am 1 Okt. 2015
I know this sounds dumb but how can I locate the error. I'm using MATLAB's profiler but I'm not learning anything from it.

Melden Sie sich an, um zu kommentieren.

Jan
Jan am 1 Okt. 2015

0 Stimmen

Please post the complete error message.
t.TimerFcn = 'Weeklys';
Try to use a function handle as TimerFcn as explained in the documentation of timer.

Kategorien

Mehr zu Programming Utilities finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Gefragt:

am 1 Okt. 2015

Beantwortet:

Jan
am 1 Okt. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by