| Stateflow User's Guide | ![]() |
Exporting Data to External Stateflow Code
A Stateflow machine can export definitions of Stateflow machine data to external code that embeds the machine. Exporting data enables external code and the Stateflow machine to access the exported data. This means that external data is visible to every Stateflow diagram in the Simulink model of the Stateflow machine.
To export data from the Stateflow machine to externally defined code, do the following:
| Note You can add exported data to the Stateflow machine only in the Model Explorer, by adding it to a Simulink model. |
For each exported data item, the Stateflow code generator generates a C declaration of the form
where type is the C type of the exported item (for example, int16, double, and so on) and data is the item's Stateflow name. For example, suppose that your Stateflow machine defines an exported int16 item named counter. The Stateflow code generator exports the item as the C declaration
where int16_T is a defined type for int16 integers in Stateflow.
The code generator includes declarations for exported data in the generated target's global header file, thereby making the declarations visible to external code compiled into or linked to the target.
See Exported Data for an example of Stateflow data exported to Stateflow external code.
| Sharing Data with Stateflow External Code | Importing Data from External Stateflow Code | ![]() |
© 1994-2005 The MathWorks, Inc.