Flow chart runs only once ?

9 次查看(过去 30 天)
Xiaohong shen
Xiaohong shen 2023-6-13
回答: Abhaya 2024-9-4
Newly I realized the flow chart in the state1 is excuted only one time at state entry. Actually I expected the cnt shall be counted up every loop as long as the state1 is active.
How can I fix it so that the flow chart is called every loop?
I found also the following note. It would mean the observed behavior is intended?
If a Stateflow chart contains only a flow chart, the chart evaluates the flow chart each time the chart wakes up. In contrast, the chart evaluates any flow chart inside a state only during state entry.

回答(1 个)

Abhaya
Abhaya 2024-9-4
Hi Xiaohong,
When you connect a Stateflow 'default transition' to a flow chart, it is designed to execute only upon entry into the state.
Please refer to the ‘Workflow for Stateflow Chart Execution’ section of the following documentation.
Below is a model similar to the model provide by you, where we can observe that the variablecnt is updated only once.
To update the variable ‘cnt with each iteration, connect the junction to the Stateflow state ‘State1’ as illustrated in the following figure.
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Complex Logic 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by