Main Content

jc_0701: Usable number for first index

Since R2020a

Guideline Publication

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

Sub ID Recommendations

  • NA-MAAB — a1/a2

  • JMAAB — a1/a2

MATLAB Versions

All

Rule

Sub ID a1

When Stateflow Chart (Stateflow) property Action language (Stateflow) is set to C, Stateflow data property First Index (Stateflow) shall be set to 0.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

First Index is set to a combination of 0, 1, and 2.

Sub ID a2

When Stateflow Chart (Stateflow) property Action language (Stateflow) is set to C, Stateflow data property First Index (Stateflow) shall be set to 1.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

First Index is set to a combination of 0, 1, and 2.

Rationale

Sub ID a1:

  • Logic becomes easier to understand when First Index is uniform.

Sub ID a2:

  • Logic becomes easier to understand when First Index is uniform. However, C language is 0-based, which decreases the readability of the code as the index calculation process is 1-based. This is reflected in the generated code.

Verification

Model Advisor check: Check usable number for first index (Simulink Check)

Last Changed

R2020a

Version History

Introduced in R2020a