himl_0003: Complexity of user-defined MATLAB Functions
R2026bLimit the size and complexity of MATLAB function code
Usage: High-Integrity System Modeling
Guideline ID: himl_0003
Rules
| himl_0003: Complexity of user-defined MATLAB® Functions |
|---|
When using MATLAB functions, limit the size and complexity of MATLAB code. The size and complexity of MATLAB functions is characterized by:
Rationale
Verification Check MATLAB Function metrics (Simulink Check) |
Tips
Size and complexity limits can vary across projects. Typical limits might be as described in this table:
Metric Limit Lines of code 60 per MATLAB function Nested function levels 31,2 Cyclomatic complexity 15 Density of comments 0.2 comment lines per line of code 1Pure Wrappers to external functions are not counted as separate levels.
2Standard MATLAB library functions do not count as separate levels.
Industry Standards
IEC 61508-3, Table B.9 (6) - Fully defined interface
IEC 62304, 5.5.3 - Software Unit acceptance criteria
ISO 26262-6, Table 1 (1a) - Enforcement of low complexity
ISO 26262-6, Table 1 (1f) - Use of unambiguous graphical representationEN 50128, Table A.1(11) - Software Interface Specifications
EN 50657, Table A.1(11) - Software Interface Specifications
EN 50716, Table A.1(11) - Software Interface Specifications
DO-331, Sections MB.6.3.1.e - High-level requirements conform to standards
DO-331, Sections MB.6.3.2.e - Low-level requirements conform to standards