How can I tell when a Stateflow state is active other than looking at it or using the Data Inspector?

5 visualizaciones (últimos 30 días)
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:
  1. Visually inspect the chart whilst stepping through a simulation to see at which timestep the given state becomes active
  2. 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?

Respuesta aceptada

Mark McBroom
Mark McBroom el 15 de Ag. de 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.

Más respuestas (0)

Categorías

Más información sobre Decision Logic en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by