How to determine a Stateflow sequence?

Hello,
I am working on Simulink using Stateflow and I have a request. I want to know if it is possible after the simulation of the model to know in which states and with which transitions the model have been runned. The goal is to know at the end of the simulation with transitions were used to reach the different states.

 Respuesta aceptada

Jonas
Jonas el 27 de Abr. de 2021
Editada: Jonas el 27 de Abr. de 2021

0 votos

In the Model Explorer, for your Stateflow chart, check 'Create output for monitoring: Child activity'. Simulink has now added another output port to your Stateflow chart. The data type will be an enumeration with your state names as values. You can add a Scope block and it will display the active state in time.
It is not possible to know which transition paths were used. You can for example have different transition paths between two states, but it will only display that 'a' transition from the one state to the other state has taken place.
I hope this at least may improve your troubleshooting of your Stateflow charts.

6 comentarios

Olivier NEYRET
Olivier NEYRET el 27 de Abr. de 2021
Thank you, it is good to see in which state we are at any time, but is there a solution to see which transition the model is using to go into these states? For example if I have different transition going to a state, I would like to know which one was used
Jonas
Jonas el 27 de Abr. de 2021
The only way is to manually add a monitor variable which you set differently depending on which transition was made, and then scope that variable.
Alternatively, you can add the command disp('Transition A') for example inside the 'action' part of the transition. This will result in 'Transition A' be displayed in the Diagnostic Viewer during simulation.
Olivier NEYRET
Olivier NEYRET el 27 de Abr. de 2021
Ok I will try this then, the problem with disp is that my chart doesn't recognize the function, my chart is in C i don't know if it has an impact.
[IntS==1]/{disp('Transition A')}
This is the text for my transition, and i get this error:
Unresolved function 'disp' in '[IntS=...on A')}'.
Jonas
Jonas el 27 de Abr. de 2021
Probably, 'disp' is a MATLAB function.
Olivier NEYRET
Olivier NEYRET el 27 de Abr. de 2021
Oh ok, and you know the equivalent in C?
Olivier NEYRET
Olivier NEYRET el 27 de Abr. de 2021
It's good i found it, it is "printf". Thanks a lot for your help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Functions en Centro de ayuda y File Exchange.

Productos

Versión

R2016b

Preguntada:

el 27 de Abr. de 2021

Comentada:

el 27 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by