In a Simulink Stateflow chart, what happens when a state is activated?
Think about what happens when you enter a room and start doing what the room is for.
When a state is activated in Stateflow, its entry actions run and it becomes the current active state until a transition occurs.
Given the following transition condition in a Stateflow chart: [x > 5], what is the output when x = 7?
x = 7; condition = (x > 5);
Check if 7 is greater than 5.
The condition x > 5 evaluates to true when x is 7.
In a Stateflow chart with two parallel states, each having two substates, how many states are active simultaneously when both parallel states are active?
Parallel states and their active substates are all active.
In parallel (AND) decomposition, both parallel states are active simultaneously. Each activates one substate (OR decomposition within each), so two parallel states + two substates = 4 active states.
Consider a Stateflow chart with two transitions from the same state: one with condition [x > 10] and another with [x > 5]. If x = 12, which transition will execute and why?
Check the order of transitions and their conditions.
Stateflow evaluates transitions in order; the first true condition transition executes, so the one with [x > 10] runs.
You need to design a Stateflow chart to control a traffic light with states: Red, Green, and Yellow. The light should cycle in this order with fixed durations: Red (5s), Green (4s), Yellow (1s). Which approach correctly models the timing and transitions?
Think about how to model timed events in Stateflow.
Using entry actions to start timers and transitions triggered by timer expiration models the fixed durations and order correctly.
