Main Content

Check MATLAB code for global variables

Check ID: mathworks.maab.na_0024

Guideline: na_0024: Shared data in MATLAB® functions

Description

Verifies that global variables are not used in any of the following:

  • MATLAB code in MATLAB Function blocks

  • MATLAB functions defined in Stateflow® charts

  • Called MATLAB functions

This check requires a Simulink® Check™ license.

Check Parameterization

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

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

Results and Recommended Actions

ConditionRecommended Action

Global variables are used in one or more of the following:

  • MATLAB code in MATLAB Function blocks

  • MATLAB functions defined in Stateflow charts

  • Called MATLAB functions

Replace global variables with signal lines, function arguments, or persistent data.

Capabilities and Limitations

  • Runs on library models.

  • Does not analyze content of library linked blocks.

  • Analyzes content in all masked subsystems.

  • Does not allow exclusions of blocks or charts.