Is it possible to add entry, during and exit actions to states that include differential equations?

13 visualizaciones (últimos 30 días)
I am trying to connect three states in Simulink out of which 2 contain differential equations (first one without, second and third with diff equation). However, I cannot put entry, during or exit commands for the middle state - it always gives an error saying the state doesn't support these actions. How can I get this to work?

Respuestas (1)

Purvaja
Purvaja el 1 de Sept. de 2025 a las 11:34
Editada: Purvaja el 1 de Sept. de 2025 a las 11:35
I faced the same issue and found that when a Simulink-based state (i.e., a state that contains a Simulink subsystem or differential equation block) is used within a Stateflow chart, Stateflow prohibits adding entry, during, or exit actions directly on that state, that’s why we were encountering the error.
You can try this workaround:
Wrap the Simulink state inside an otherwise empty parent Stateflow state, and place your entry, during, or exit actions in that parent. Inside the parent, you can have a default transition going to the Simulink-based child state (but ensure that the initialisation of variables are taken care of in this case). This approach allows you to attach the actions where needed without errors.
I tried a dummy example with 3 states as you intended.
As you can see above, S1 has no ODEs, while S2 and S3 contain differential equations. Here, "u" is input variable and "x" & "y" are output variables. Ensure that their "Update Method" parameter is set to "continuous".
I came up with this workaround with the help of below answer on MATLAB Answers Community:
Hope this resolves your issue.

Categorías

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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by