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?

답변 (2개)

Sean de Wolski
Sean de Wolski 2015년 10월 1일

0 개 추천

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

Cary
Cary 2015년 10월 1일
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.

댓글을 달려면 로그인하십시오.

Jan
Jan 2015년 10월 1일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

태그

질문:

2015년 10월 1일

답변:

Jan
2015년 10월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by