Stateflow transition does not work when using output bus field
Show older comments
Hello together,
I am facing a strange behaviour of my Simulink model. That model is comprised of a Simscape subsystem and a Stateflow subsystem. The latter is used to controll the operation mode of the Simscape model.
For a clear data transfer I implemented several data buses as Stateflow inputs and outputs. For that, I created the necessary Simulink Bus Objects and it works fine so far. But when I want to use one field of the Getoperationdata bus to describe the transition condition, the transition is not exceeded despite the condition is true (as shown in the figure below). The state Empty_Pump_Chamber remains active but should switch to Empty_Complete.

The Getoperationdata bus is implemented as an output bus. When defining a transition condition with a variable from another input bus, the model succeeds. Very strange. Even when I define a local variable, set this variable equal to Getoperationaldata.emptyComplete2 and use this new variable to state the transition condition, the model succeeds. Very strange! What is wrong?
Kind Regards!
1 Comment
Guillermo
on 15 Apr 2026 at 15:36
Answers (1)
Simran
on 20 Apr 2026 at 14:43
I see you're trying to use an output bus field (Getoperationdata.emptyComplete2) as a transition condition in your Stateflow chart to control the operation modes of your Simscape model.
Assuming you have the output bus configured correctly and the value does get set to "true" during state execution, I think the issue is happening because output data in Stateflow has different timing and scope than local variables.
When you set "Getoperationdata.emptyComplete2 = true" inside the "Empty_Pump_Chamber" state, that value is written to the output bus, but Stateflow may reset or flush output values as part of its execution cycle. By the time the transition condition is evaluated, the output field may already be back to its initial value (false), so the transition never fires. This explains why you see it as "true" right before the transition but "false" right after.
You could try:
1.) Use a local variable for the transition condition (which you already discovered works):
% In Empty_Pump_Chamber state:
localComplete = true;
Getoperationdata.emptyComplete2 = localComplete;
% Transition condition:
[localComplete == true]
2.) Use Data Store Memory for persistent state that needs to survive across execution cycles
3.) Check your chart's execution order settings - make sure state actions complete before transition evaluation
The key is to separate concerns: use local/persistent variables for control flow and output buses only for sending data out of the Stateflow chart to other Simulink blocks.
Let me know if this helps!
1 Comment
Guillermo
on 22 Apr 2026 at 14:28
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!
