This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Access Custom Code Variables and Functions in Stateflow Charts

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.

Custom Code Variables in Charts That Use MATLAB as the Action Language

You can read and write the following C code variables directly in your charts that use MATLAB® as the action language.

Custom C Code TypeDescription
doubleDouble-precision floating point
singleSingle-precision floating point
int8Signed 8-bit integer
uint8Unsigned 8-bit integer
int16Signed 16-bit integer
uint16Unsigned 16-bit integer
int32Signed 32-bit integer
uint32Unsigned 32-bit integer

By right clicking on the Stateflow object that uses your custom code, you can access your custom code variable. After right clicking on the object, hover over Explore. Your custom code variable appears, denoted by (C variable). Clicking the C variable allows you to access the custom code from MATLAB.

Custom Code Functions in Charts That Use MATLAB as the Action Language

You can use the following C function argument types directly in your charts that use MATLAB as the action language without using coder.ceval. For information on calling external code from MATLAB code by using coder.ceval, see Call C/C++ Code from MATLAB Code (MATLAB Coder).

Custom C Function Argument TypeDescription
doubleDouble-precision floating point
singleSingle-precision floating point
int8Signed 8-bit integer
uint8Unsigned 8-bit integer
int16Signed 16-bit integer
uint16Unsigned 16-bit integer
int32Signed 32-bit integer
uint32Unsigned 32-bit integer

By right clicking on the Stateflow object that uses your custom code, you can access your custom code function. After right clicking on the object, hover over Explore. Your custom code function appears, denoted by (C function). Clicking the C function allows you to access the custom code from MATLAB.

Related Topics