| Stateflow User's Guide | ![]() |
Introduction to Embedded MATLAB Functions
A Stateflow Embedded MATLAB function contains an Embedded MATLAB language function. The Embedded MATLAB language is a powerful subset of the MATLAB language that, like the rest of Stateflow, generates efficient C code for embeddable applications.
Simulink uses Stateflow Embedded MATLAB functions to implement Embedded MATLAB blocks in Simulink models. See Using the Embedded MATLAB Function Block in Simulink documentation for more information on Embedded MATLAB blocks in Simulink.
You build the following model in Building a Simulink Model with a Stateflow Embedded MATLAB Function:
In addition to supporting MATLAB syntax, a Stateflow Embedded MATLAB function can call any of the following functions:
Subfunctions are defined in the body of the Embedded MATLAB function. In the preceding example, avg is a subfunction.
Embedded MATLAB run-time library functions are a subset of the functions that you can call in MATLAB. They generate C code for building targets that conforms to the memory and data type requirements of embedded environments. In the preceding example, length, sqrt, and sum are examples of Embedded MATLAB run-time library functions.
Includes graphical, truth table, and other Embedded MATLAB functions in the scope of the current Embedded MATLAB function.
Function calls that cannot be resolved as subfunctions, Embedded MATLAB run-time library functions, or Stateflow functions are resolved in the MATLAB workspace. These functions do not generate code; they execute only in the MATLAB workspace during simulation of the model.
| Using Embedded MATLAB Functions | Building a Simulink Model with a Stateflow Embedded MATLAB Function | ![]() |
© 1994-2005 The MathWorks, Inc.