Main Content

Check switch statements in MATLAB Function blocks

Check ID: mathworks.hism.himl_0007

Description

This check identifies the switch/case/otherwise statements without appropriate conditions in embedded MATLAB code.

Available with Simulink® Check™.

Results and Recommended Actions

ConditionRecommended Action
Switch statement does not have any otherwise condition.Make sure that the switch statement has an otherwise condition.
Otherwise statement is left blank with no comments.Make sure that the otherwise statement has at least one meaningful comment.
Switch statement has only one case statement.Make sure that the switch statement has at least two case statements.

Capabilities and Limitations

  • This check excludes a single case statement with a cell array of two or more elements.

  • This check only analyzes the functions that are directly referenced by the Simulink model.

  • Runs on library models.

  • You can configure the check to run on referenced MATLAB files using the input parameter Check .m files referenced in the model in the Configuration Editor. By default this parameter is selected.

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

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

  • Allows exclusions of blocks and charts.

See Also