How to count how many times a state is visited?

3 ビュー (過去 30 日間)
Grace Edlin
Grace Edlin 2021 年 5 月 5 日
コメント済み: Grace Edlin 2021 年 5 月 5 日
I want to count how many times a state is visited within Stateflow. I would like it to have a counter so if it gets visited 10 times it goes to a fault condition. It needs to be able to handle visiting in between states.
For example if it goes from state A -> B -> A the counter for A would be 2.
I've looked at count, before and temporalCount and none seem to act as desired.

採用された回答

Jonas
Jonas 2021 年 5 月 5 日
Write the following inside state A:
en:
counter = counter + 1;
and initialise counter = 0. The counter will be incremented only when state A is entered, hence the 'en' command.
  1 件のコメント
Grace Edlin
Grace Edlin 2021 年 5 月 5 日
Ah yes. I needed it as a local variable. Thank you :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by