How can I tell when a Stateflow state is active other than looking at it or using the Data Inspector?
5 views (last 30 days)
Show older comments
I am creating a model to test a stateflow chart in a library. I would like to set the input data and check that a given state within the chart becomes active at the time it should. Ideally, I would like to do this without editing the chart at all.
Currently I have two ways of achieving this:
- Visually inspect the chart whilst stepping through a simulation to see at which timestep the given state becomes active
- In the prepare section of the Simulation pane, adding a "Log Active State" to the given state, running a simulation and then checking the Data Inspector to see if/when it became active.
Both of these require visual confirmation for the result of the test, which is acceptable but not preferred. I would like, if possible, a way to get the results of the test without needing visual confirmation, such as using an assertion block.
Is there any way to do this either through the model, or maybe exporting the data from the Data Inspector and checking against that?
0 Comments
Accepted Answer
Mark McBroom
on 15 Aug 2025
Stateflow can be configured to output the current state as an output port from the chart. You can then add assertion blocks on the signal to check for proper state.
More Answers (0)
See Also
Categories
Find more on Decision Logic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!