Main Content

mp_0007: How to describe executable statements

Since R2024b

Guideline Publication

Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®

Sub ID Recommendations

  • NA-MAAB — a, b

  • JMAAB — a, b

MATLAB Versions

All

Rule

Sub ID a

Multiple execution statements shall not be written in a single line.

Example — Correct

if foo > 0
   bar = 10;
end

Example — Incorrect

if foo > 0;bar = 10;
end

Sub ID b

Executable statements shall end with a semicolon.

Example — Correct

foo = 1 + 2;

Example — Incorrect

foo = 1 + 2

Rationale

Sub IDs a:

  • Readability is improved by standardizing the way to write statements according to common practices.

Sub ID b:

  • Readability is improved by standardizing the way to write statements according to common practices.

  • If you execute a statement without a semicolon, the results are displayed in the Command Window, and you might miss important warnings.

Verification

Model Advisor check: Check description of execution statements (Simulink Check)

Last Changed

R2024b

Version History

Introduced in R2024b