Main Content

Check use of single variable variant conditionals

Check ID: mathworks.maab.na_0037

Guideline: na_0037: Use of single variable for variant condition

Description

Check use of single variables in conditional expressions

Checks Variant Subsystem, Variant Source, Variant Sink, and variant Model blocks for conditional expressions that have more than one variable.

Note

Guideline na_0037 states that default variants are an exception to the recommendation of writing variant conditional expressions using multiple variable with a single condition. You can define a default by:

  • Selecting (default) in the block parameter Variant control.

  • Specifying an exhaustive condition.

This check cannot differentiate between defaults that are defined using an exhaustive condition.

This check requires a Simulink® Check™ license.

Examples for expected check behaviour for acceptable variant conditions include:

  • Pass case 1: Only one variant condition has multiple variables with single condition (same condition or single condition, x==0 is assumed as default case):

    • var1 IN==0 && OUT==0

    • var2 IN==1

  • Pass case 2: Variant conditions with same variable with multiple condition:

    • var1 IN==0 && IN==1

    • var2 OUT==1 && OUT==2

Examples for expected check behaviour for violating variant conditions include:

  • Violation case 1: More than one variant condition has multiple variables with single condition:

    • var1 IN==0 && OUT==0

    • var2 IN==1 && OUT==1

  • Violation case 2: More than one variant condition has multiple variables with multiple condition:

    • var1 IN==1 && OUT==2

    • var2 IN==2

  • Violation case 3: One of the variant conditions is default and other one has multiple variables with single condition. This is not acceptable case as more than one default variant is not allowed:

    • var1 IN==0 && OUT==0

    • var2 default

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
Conditional expression contains more than one condition variable.Consider updating your model so that only one variant is used.

Conditional expression variable or Simulink.Variant object is not found in the workspace.

Consider defining a variant in your model.
Check does not execute on my variant subsystem. Clear Override variant conditions and use following variant for the variant subsystem.

Capabilities and Limitations

  • Does not check default variants.

  • Does not run on the Variant subsystem when you select Override variant conditions and use following variant

  • Runs on library models.

  • Analyzes content of library linked blocks.

  • Analyzes content in all masked subsystems.