How to locate an error in a timer callback?

4 ビュー (過去 30 日間)
Yanxin Liu
Yanxin Liu 2021 年 10 月 21 日
回答済み: Jon 2021 年 10 月 21 日
Normally when we have an error in script we see something like: "Error xxx (line x)".
But when there is an error in timer callback it shows:
Error while evaluating TimerFcn for timer 'timer-1'
Error xxx
From which I couldn't know which line went wrong.
Anyone know how I can locate the error?
Thanks

採用された回答

Jon
Jon 2021 年 10 月 21 日
I also have had a lot trouble with this. One thing that can help is to wrap the code where the problem occurs within a try catch and explicitly rethrow the error message. You can also put a debug breakpoint inside of the timer function and then step through to see where it goes wrong.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by