Main Content

Check for operator precedence

Check ID: mathworks.jmaab_v6.mp_0010

Guideline: mp_0010: Precedence of operators in arithmetic expressions

Description

Checks if expressions with operators of different precedence use parentheses to clarify the order of operations.

For details, see Operator Precedence.

This check applies to expressions in the following target components:

  • MATLAB Function blocks in Simulink®.

  • Embedded MATLAB® functions in Stateflow® charts.

  • States, transitions, and truth tables in Stateflow MATLAB charts.

  • External MATLAB files referenced in a model.

This check requires a Simulink Check™ license.

Check Parameterization

This check does not include sub-checks because the JMAAB modeling guideline provides only one sub ID.

For reference, the guideline sub ID(s) that are recommended for use by the JMAAB modeling standards organizations are:

  • JMAAB — a

Select Check external .m files referenced in the model, to include files with a .m extension in the analysis. The check box is selected by default.

Results and Recommended Actions

ConditionRecommended Action
One or more expressions with operators of different precedence do not use parentheses to clarify order of operations.Rewrite expressions to clarify order of operations using parentheses.

Capabilities and Limitations

  • Does not analyze states and transition labels in Stateflow charts.

  • Does not support exclusions of external MATLAB files.

  • Analyzes content of library-linked blocks. By default, the input parameter Follow links is set to on.

  • Analyzes content in masked subsystems. By default, the input parameter Look under masks is set to all.

  • Runs on library models.

  • Allows exclusion of blocks and charts.

See Also