Main Content

Preserve operand order in expression

Preserve order of operands in expressions

Model Configuration Pane: Code Generation / Code Style

Description

Specify whether to preserve order of operands in expressions.

Settings

off (default) | on

Default: off

On

Preserves the expression order specified in the model. Select this option to increase readability of the code or for code traceability purposes.

Note

This setting applies to Embedded Coder® only and might not affect order of operands inside Stateflow® charts.

Off

Optimizes efficiency of code for nonoptimized compilers by reordering commutable operands to make expressions left-recursive.

Examples

expand all

Compare the order of operands in expressions in the generated code when you set Preserve operand order in expression to different values.

Here is generated code that generated using the default Preserve operand order in expression value off:

(B+C)*A

Here is the same code generated with Preserve operand order in expression set to on:

A*(B+C)

Recommended Settings

ApplicationSetting
DebuggingOn
TraceabilityOn
EfficiencyOff
Safety precaution

No recommendation

Programmatic Use

Parameter: PreserveExpressionOrder
Type: character vector
Value: 'on' | 'off'
Default: 'off'

Version History

Introduced in R2007a