How to transfer data between two separate Stateflow Chart blocks in Simulink?
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am working on a Simulink model where I have two separate Stateflow Chart blocks: Block A and Block B. In Block A, I perform some operations on the input signal, and I want to pass the result to Block B. In Block B, I intend to add a bias to this received data and output the final result.
However, I am facing challenges in connecting these two Chart blocks. Specifically:
- How can I properly pass data from one Stateflow Chart to another?
What is the correct way to structure this model? Should I use Inport/Outport connections with Simulink signal lines between the charts?
Any example, official documentation, or detailed explanation would be highly appreciated.
Thanks in advance!
Image:




0 commentaires
Réponses (2)
Aabha
le 21 Avr 2025
I noticed that you are using two separate ‘Simulink-based State Blocks’ inside the ‘Stateflow’ chart. These blocks are usually used to model systems that switch between periodic or continuous time dynamics, or similar complex computations. In this case, since the computation is fairly simple, it would be better to use ‘State’ blocks and use ‘State variables’ instead of ‘Simulink signals.’
However, if you wish to use ‘Simulink-state Based Blocks’, data can be transferred between them by using ‘Inport’ and ‘Outport’ blocks. In this case, the two states ‘A’ and ‘B’ should be separated into two separate ‘Stateflow Charts.’ Once that is done, add an ‘Outport’ block inside ‘A’, and an ‘Inport’ block inside ‘B’. This should create input and output ports for their respective ‘Stateflow charts’, which can be directly connected.
For more information about using ‘Simulink-based States’, please refer to the following documentation:
I hope this helps.
0 commentaires
Corey Lagunowich
le 6 Mai 2025
Semih,
If you want Task A and Task B to run in the same timestep, then these should be either parallel states or two separate charts, as Aabha suggests. Otherwise, as drawn, State A wil be active only on the first timestep, then the transition to State B will occur on the second timestep; State B will continue to be active for the rest of the simulation since there's no outgoing transition. Thus, Task B blocks will run every timestep thereafter.
0 commentaires
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!