Main Content

Arithmetic operations in variant conditions

Description

Select the diagnostic action to take if Simulink® software detects arithmetic operations (+, -, *, idivide, rem) in variant conditions specified within variant blocks.

Category: Diagnostics

Settings

Default: error

Note

For models created prior to R2019a, the default value is warning.

none

When Simulink software detects arithmetic operations in variant conditions of a Variant block with the Variant activation time option set to code compile, the software takes no action.

warning

When Simulink software detects arithmetic operations in variant conditions of a Variant block with the Variant activation time option set to code compile, the software displays a warning.

error

When Simulink software detects arithmetic operations in variant conditions of a Variant block with the Variant activation time option set to code compile, the software displays a warning and terminates the simulation.

Note

It is recommended to use the default value error, as there could be a difference in behavior between simulation and code generation. For example, if you use the condition V * W == 10 in a Variant Source block and request that the block produces preprocessor conditions in the Simulink Coder generated code. This results in generated C code containing "#if V*W == 10". Simulink uses int32 types for V and W, whereas the integer types used by the compiler are implementation dependent. So, for large values of V and W, there could be a difference in behavior between simulation and code generation. If the model uses arithmetic operations, you must consider removing their usage rather than relaxing the diagnostic.

Command-Line Information

Parameter: ArithmeticOperatorsInVariantConditions
Value: 'none' | 'warning' | 'error'
Default: 'error'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Related Topics