Main Content

MATLABFunction Block Basics

Integrate MATLAB®functions into Simulink®models

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

Tools

MATLAB Function Block Editor Create, edit, and debugMATLABcode inMATLABFunction blocks

Blocks

MATLAB Function IncludeMATLABcode in models that generate embeddable C code

Objects

MATLABFunctionConfiguration MATLABFunction block property configuration
Stateflow.EMChart Stateflowinterface toMATLABFunction 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 aMATLAB Functionblock 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

运行模拟和生成代码与模型强g customMATLAB Functionblocks in a library.

Integration Considerations for MATLAB Function Blocks

Integrate aMATLAB Functionblock into your Simulink model.

Call MATLAB Function Files in MATLAB Function Blocks

UseMATLAB Functionblocks to call and execute code written in MATLAB function files.

Integrate C Code by Using the MATLAB Function Block

UseMATLAB Functionblocks to call external C code and control enumeration and bus typedefs.

Troubleshooting

Debug MATLAB Function Blocks

DebugMATLAB Functionblock code during simulation.

Prevent Algebraic Loop Errors in MATLAB Function and Stateflow Blocks

Adhere to restrictions for usingMATLAB Functionblocks, 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.