Main Content

na_0016: Source lines of MATLAB Functions

Since R2020a

Guideline Publication

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

Sub ID Recommendations

  • NA-MAAB — a

  • JMAAB — Not supported

MATLAB Versions

All

Rule

Sub ID a

The length of MATLAB functions shall be limited. The recommended limit is 60 lines of code. Sub-functions can use an additional 60 lines of code.

This restriction applies to MATLAB functions that reside in the Simulink block diagram and external MATLAB files with a .m extension.

Custom Parameter

Maximum effective lines of code per function

Rationale

Sub ID a:

  • Improves readability and workflow

  • Code generation may not be possible.

Verification

Model Advisor check: Check lines of code in MATLAB Functions (Simulink Check)

Last Changed

R2020a

Version History

Introduced in R2020a