After creating components in Stateflow, you can integrate them with other components to build your state machine algorithm. Stateflow components can contain MATLAB and Simulink functions, custom C code, graphical functions, and truth tables. In your algorithm, you can schedule component and function execution using time-based and condition-based logic.
Each Stateflow component can be developed, executed, and verified independently, enabling multiple users to work on different parts of the algorithm at the same time.
You can reuse a component across diagrams and models by right-clicking it, converting it to an atomic subchart, and placing it in a library. To use the component, you drag it from the library and drop it into your diagram or model. When you update a component in the library, all instances of the component are automatically updated. You can organize components and functions hierarchically to represent your system concisely and accurately.
Reusing States Multiple Times in a Diagram
Create and reuse components in Stateflow for large-scale modeling.
You can model conditional and time-based logic in Stateflow to call Simulink functions and MATLAB functions. Events based on logic modeled in Stateflow can be output to Simulink to activate subsystems that react to a function call or to changes in the control signal.
Stateflow provides event-based and time-based operators (before, after, at, and every) that let you specify state-transition logic based on event counts and elapsed time without using timers and counters.