Main Content

Check usage of recommended patterns for Switch/Case statements

Check ID: mathworks.maab.na_0022

Guideline:

Description

Checks for use of non-constant variables in Switch/Case statements.

In generated code, MATLAB® Function block inputs are passed as functional arguments. This check evaluates the Switch/Case statements in the generated code to determine if non-constant values are being used in the Case argument.

This check requires a Simulink® Check™ license.

Check Parameterization

This Model Advisor check is not applicable for JMAAB modeling guidelines.

This check does not include sub-checks

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

  • NA-MAAB — a

  • JMAAB — a

You can use Model Advisor Configuration Editor to configure this check to include files with a .m extension in the analysis. To enable this feature, in the Input Parameters section, select Check external .m files referenced in the model.

Results and Recommended Actions

ConditionRecommended Action
Non-constant variables are used in the Switch/Case statement.Consider defining the input variable as a constant.

Capabilities and Limitations

  • This check also implements the JMAAB v6.0 guideline: mp_0020

  • Runs on library models.

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

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

See Also