Main Content

MATLAB Function Block Basics

Integrate MATLAB® functions into Simulink® models

Use MATLAB Function block to implement MATLAB functions to Simulink models to deploy code and embed code in processors. Using MATLAB Function block, you can generate readable, efficient, and compact C/C++ code for deployment to desktop and embedded applications.

Tools

MATLAB Function Block EditorCreate, edit, and debug MATLAB code in MATLAB Function blocks

Blocks

MATLAB FunctionInclude MATLAB code in models that generate embeddable C code

Objects

MATLABFunctionConfigurationMATLAB Function block property configuration
Stateflow.EMChartStateflow interface to MATLAB Function block

Simulink Configuration Parameters

Topics

Implementing MATLAB Functions Using Blocks

Add MATLAB functions to Simulink models.

Create Custom Functionality Using MATLAB Function Blocks

Follow workflow for integrating a MATLAB Function block in a Simulink model.

Resolve Signal Objects for Output Data

Manage implicit signal resolution at various levels of the model hierarchy.

Run Simulations and Generate Code with Masked Library Subsystems Containing MATLAB Function Blocks

Run simulations and generate code with models using custom MATLAB Function blocks in a library.

Integration Considerations for MATLAB Function Blocks

Integrate a MATLAB Function block into your Simulink model.

Call MATLAB Function Files in MATLAB Function Blocks

Use MATLAB Function blocks to call and execute code written in MATLAB function files.

Integrate C Code by Using the MATLAB Function Block

Use MATLAB Function blocks to call external C code and control enumeration and bus typedefs.

Troubleshooting

Debug MATLAB Function Blocks

Debug MATLAB Function block code during simulation.

Prevent Algebraic Loop Errors in MATLAB Function and Stateflow Blocks

Adhere to restrictions for using MATLAB Function blocks, Stateflow® charts, and Truth Tables in feedback loops.

Initialize Persistent Variables in MATLAB Functions

Specialized semantics impact the way that a function initializes persistent data.