Real-Time Workshop User's Guide    

Generating Code and Executables from Subsystems

The Real-Time Workshop can generate code and build an executable from any subsystem within a model. The code generation and build process uses the code generation and build parameters of the root model.

To generate code and build an executable from a subsystem:

  1. Set up the desired code generation and build parameters in the Simulation Parameters dialog, just as you would for code generation from a model.
  2. Select the desired subsystem block.
  3. Right-click on the subsystem block and select Build Subsystem from the Real-Time Workshop submenu of the subsystem block's context menu.

    Alternatively, you can select Build Subsystem from the Real-Time Workshop submenu of the Tools menu. This menu item is enabled when a subsystem is selected in the current model.

  1. A window displaying a list of the subsystem parameters opens. You can declare any parameter to be tunable by selecting its check box in the Tunable column.)

    In the illustration above, the parameter K is declared tunable.

  1. After selecting tunable parameters, click the Proceed button. This initiates the code generation and build process.
  2. The build process displays status messages in the MATLAB command window. When the build completes, the generated executable is in your working directory. The name of the generated executable is subsystem.exe (PC) or subsystem (UNIX), where subsystem is the name of the source subsystem block.

    The generated code is in a build subdirectory, named subsystem_target_rtw, where subsystem is the name of the source subsystem block and target is the name of the target configuration.


 Modularity of Subsystem Code Parameters: Storage, Interfacing, and Tuning