You can integrate custom code written in C or C++ with Stateflow® charts in Simulink® models. By sharing data and functions between your custom code and your Stateflow chart, you can augment the capabilities of Stateflow and leverage the software to take advantage of your preexisting code. For more information, see Reuse Custom Code in Stateflow Charts.
Specify custom code options in the simulation target for each library model that contributes a chart to the main model:
In the Modeling tab, select Model Settings.
The Model Configuration Parameters dialog box appears. Open the Simulation Target pane.
Select Use local custom code settings (do not inherit from main model).
This step ensures that each library model retains its own custom code settings during simulation.
Specify your custom code in the subpanes.
Follow the guidelines in Specify Relative Paths to Your Custom Code.
See Task 1: Include Custom C Code in the Simulation Target for descriptions of the custom code options.
Simulate your model by clicking the play button in the toolbar of the editor.
For information on setting simulation options using the command-line API, see Command-Line API to Set Simulation and Code Generation Parameters.
You cannot simulate only the Stateflow blocks in a library model. You must first create a link to the library block in your main model and then simulate the main model.