Generate Code and Executables for Individual Subsystems - MATLAB & Simulink (original) (raw)

Main Content

You can generate code and build a standalone executable for a subsystem within a model. When you generate code for an individual subsystem, the code generation and build process uses the code generation and build parameters of the root model.

  1. Open a model with a subsystem, such as SubsystemAtomic.
    openExample('SubsystemAtomic')
  2. Open Simulink® Coder™ or Embedded Coder®.
    If you are using Embedded Coder, from the tab, click View Code to open the Code View editor.
  3. Right-click the Subsystem block. From the context menu, click . From the Block Parameters: SS1 window, open the Code Generation tab.
  4. Use the Function name options and File name options parameters to control the names of the generated functions and files. Set the Function name options parameter to Auto so that the code generator uses the name of the subsystem in the generated file names.
  5. Right-click the Subsystem block. From the context menu, select .
  6. To configure properties such as the name, class, and storage class of variables (or data objects) that are referenced as block parameters in the subsystem, convert the subsystem to a Model block. Configure the properties through the Code Mappings editor.
    For more information on tunable and inlined parameters and storage classes, see Create Tunable Calibration Parameter in the Generated Code.
    The build process displays status messages in the MATLAB® Command Window. When the build is complete, the generated executable is in your working folder. The name of the generated executable is_`subsystem`_.exe (on PC platforms) or_`subsystem`_ (on The Open Group UNIX® platforms). _`subsystem`_ is the name of the source Subsystem block. In this example, theSubsystem block is named SS1.
    The generated code is in a build subfolder named_`subsystem`__ _`target`__rtw._`subsystem`_ is the name of the source subsystem block and _`target`_ is the name of the target configuration.

Subsystem Build Limitations

These limitations apply to building subsystems:

See Also

Topics