System Objects in MATLAB Code Generation - MATLAB & Simulink (original) (raw)

Main Content

You can generate C/C++ code in MATLAB® from your system that contains System objects by using MATLAB Coder™. You can generate efficient and compact code for deployment in desktop and embedded systems and accelerate fixed-point algorithms.

Usage Rules and Limitations for System Objects for Generating Code

The following usage rules and limitations apply to using System objects in code generated from MATLAB.

Object Construction and Initialization

Inputs and Outputs

Properties

Global Variables

Methods

System Objects in codegen

You can include System objects in MATLAB code in the same way you include any other elements. You can then compile a MEX file from your MATLAB code by using the codegen command, which is available if you have a MATLAB Coder license. This compilation process, which involves a number of optimizations, is useful for accelerating simulations. See Get Started with MATLAB Coder andMATLAB Classes for more information.

Note

Most, but not all, System objects support code generation. Refer to the particular object’s reference page for information.

System Objects in the MATLAB Function Block

Using the MATLAB Function (Simulink) block, you can include any System object and any MATLAB language function in a Simulink model. This model can then generate embeddable code. System objects provide higher-level algorithms for code generation than do most associated blocks. For more information, see Implement MATLAB Functions in Simulink with MATLAB Function Blocks (Simulink).

System Objects in the MATLAB System Block

Using the MATLAB System (Simulink) block, you can include in a Simulink model individual System objects that you create with a class definition file. The model can then generate embeddable code. For more information, see Create Custom Blocks Using MATLAB System Block and System objects (Simulink).

System Objects and MATLAB Compiler Software

MATLAB Compiler™ software supports System objects for use inside MATLAB functions. The compiler product does not support System objects for use in MATLAB scripts.