Search code examples
matlabchartssimulinkstatechartstateflow

Transition Action and Condition Action in Stateflow


In the below two state charts , the first one has an action to perform when it moves from StateA to StateD , ie. /{z=5}; and the second one has to perform the action {z=5}; I understand that this is a Transition Action , but i am unable to understand what is the different between the two transition

enter image description here

enter image description here


Solution

  • See the link given by @am304 for specific information, but in brief,

    • in your first image you have a Transition Action, which executes when the transition occurs (and after any state exit actions - if you had any for State A),

    • in your second image you have a Condition Action, which executes when any condition associated with the transition is determined to be true. You do not have any explicit conditions (i.e. nothing like e1[cond1]{z = 5}) so the condition is considered to be true when any event occurs. This will execute even if the transition is not made (i.e. it is only dependent on the condition.) This means that it would occur before any state exit action (if you had any for State A.)

    Given the above, in your specific case (i.e. no exit actions for State A and no conditions on the transition), the two will give the same result.