For models that contain variant blocks, variant parameters or use symbolic dimensions, generate code with preprocessor conditionals. For variant blocks and parameters, 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.
- 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.
- 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.
- 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.
- Generate Preprocessor Conditionals for Variant Systems
Define variant control variables and configure model for generating preprocessor conditional directives.
- Code Generation for Variant Blocks
Generate code containing preprocessor conditionals that control the active variant choice for a Simulink® model containing variant blocks.
- Represent Variant Condition Values of Enumerated Type in Generated Code
You can generate C code from a Simulink® model with variant condition variables or values of Simulink-supported Use Enumerated Data in Simulink Models.
- Options to Represent Variant Parameters in Generated Code
You can generate the code only for active values or for both active and inactive values of variant parameters in Simulink.
- Compile Code Conditionally for All Values of Variant Parameters with Same and Different Dimensions
This example shows how to generate a C code that contains all the active and inactive values of variant parameters.
- Improve Code Readability of Variant Parameters Using Enumerated Types
You can use enumerated types to improve code readability of variant control values in variant parameters.
- Reuse Variant Parameter Values from Handwritten Code Using Simulink.Parameter Variables
This example shows how to use
variables to generate a code that imports variant parameter values from your existing code.
- Run Executable for Different Variant Parameter Values Without Recompiling Code
This example shows how to generate an executable that runs for different set of variant parameter values without needing to recompile the code for each set of values.
- Implement Symbolic Dimensions 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.
- Configure Symbolic Dimensions for S-Function Blocks
Configure S-functions to support forward propagation, backward propagation, or forward and backward propagation of symbolic dimensions during simulation.
- 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.