State actions and transition conditions can be complicated enough that defining them inline on the state or transition is not feasible. In this case, express the conditions or actions using one of the following types of Stateflow® functions:
Flow chart — Encapsulate flow charts containing if-then-else, switch-case, for, while, or do-while patterns.
MATLAB — Write matrix-oriented algorithms; call MATLAB functions for data analysis and visualization.
Simulink — Call Simulink function-call subsystems directly to streamline design and improve readability.
Truth table — Represent combinational logic for decision-making applications such as fault detection and mode switching.
Use the function format that is most natural for the type of calculation required in the state action or transition condition.
If the four standard types of Stateflow functions do not work, you can write your own C or C++ code for integration with your chart. For more information about custom code integration, see Share Data Using Custom C Code.