Use of if-else inside timer

3 ビュー (過去 30 日間)
MeEngr
MeEngr 2014 年 12 月 5 日
コメント済み: MeEngr 2014 年 12 月 7 日
Hi all,
Does anyone know if an if-else can be used inside a timer? Like, I'm running a timer. I want that after 3 seconds, it checks to see if a condition is true and then executes the code block if it is so. Else, it should do something else. Is this possible?
I had this in mind: t = timer('TimerFcn', 'if n == 23 {do something} else {do something else} end', 'StartDelay', 3); start(t)
I would be thankful for any help.

採用された回答

Image Analyst
Image Analyst 2014 年 12 月 5 日
Sure. But I don't know if the absolute elapsed time is available in the timer callback function (I doubt it), so you might have to use persistent variables (look it up) to keep track of that.
  1 件のコメント
MeEngr
MeEngr 2014 年 12 月 7 日
All right, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by