Main Content


Check state activity



in(state_name) returns 1 (true) if the state state_name is active. Otherwise, the operator returns 0 (false).


expand all

Check the substate activity in state Fan to keep the substates of state Heater synchronized.

When Fan.On becomes active, transition from Heater.Off to Heater.On.


When Fan.Off becomes active, transition from Heater.On to Heater.Off.


Stateflow chart with two superstates called Fan and Heater. Each superstate has two substates called On and Off.

A change of active substate in Fan causes a corresponding change of active substate in Heater.

Set the value of airflow to the number of fans that are turned on.

airflow = in(FAN1.On) + in(FAN2.On);

Stateflow chart that uses the in operator in a state.


To determine the state activity, a Stateflow® chart performs a localized search of the state hierarchy. The chart does not perform an exhaustive search for all states and does not stop after finding the first match. To improve the chances of finding a unique search result:

  • Use dot notation to qualify the name of the state.

  • Give states unique names.

  • Use states and boxes as enclosures to limit the scope of the path resolution search.

Additionally, a chart cannot use the in condition to trigger actions based on the activity of states in other charts.

For more information, see Resolution of State Activity.

Version History

Introduced before R2006a