Main Content

Variant Systems

Generate code for dimension, subsystem, and variant models, and for models containing Variant Sink and Variant Source blocks

For models that contain variant blocks or use symbolic dimensions, generate code with preprocessor conditionals. For variant blocks, preprocessor conditionals defer the choice of active variant until compilation time or they do not allow an active variant choice. For symbolic dimensions, preprocessor conditionals define constraints established among symbols during simulation.

Topics

Represent Subsystem and Variant Models in Generated Code

Create a model with subsystem or variant models. Generate code that contains preprocessor conditionals that control the activation of each variant choice.

Implement Dimension Variants for Array Sizes in Generated Code

Specify dimension information as symbols in blocks and data objects. These symbols propagate throughout the model during simulation and then go into the generated code.

Represent Variant Source and Sink Blocks in Generated Code

Generate code that contains preprocessor conditionals that control the activation of each variant choice and allow for no active variant choice.

Represent Variant Condition Values of Enumerated Type in Generated Code

Generate C code from Simulink® models having variant condition values of enumerated type.

Generate Preprocessor Conditionals for Variant Systems

Define variant control variables and configure model for generating preprocessor conditional directives.

Configure Dimension Variants for S-Function Blocks

Configure S-functions to support forward propagation, backward propagation, or forward and backward propagation of symbolic dimensions during simulation.

Code Generation for Variant Blocks

Generate code containing preprocessor conditionals that control the active variant choice for a Simulink model containing variant blocks.

Generate Code for Variant Subsystem with Child Subsystems of Different Output Signal Dimensions

This example shows how to use symbolic dimensions to generate code for a variant subsystem consisting of child subsystems of different output signal dimensions.

Use Variant Models to Generate Code That Uses C Preprocessor Conditionals

This example shows you how to use model variants to generate code that uses preprocessor conditionals to control which code is linked into the embedded executable.