cgsl_0101: Zero-based indexing
ID: Title | cgsl_0101: Zero-based indexing | ||
---|---|---|---|
Description | Use zero-based indexing for blocks that require indexing. To set up zero-based indexing, do one of the following: | ||
A | For the Index Vector block
parameter Data port order, select Zero-based
contiguous . | ||
B | Set block parameter Index
mode to
| ||
Notes | The C language uses zero-based indexing. | ||
Rationale | A, B | Use zero-based indexing for compatibility with integrated C code. | |
A, B | Results in more efficient C code execution. One-based indexing requires a subtraction operation in generated code. | ||
See Also | hisl_0021: Consistent vector indexing method | ||
Last Changed | R2011b | ||
Examples | Recommended void ZeroIndex(void) { Y.Out5 = 3.0 * ZeroIndexArray[IndexSel_Zero]; } | ||
Not Recommended void OneIndex(void) { Y.Out1 = OneIndexArray[IndexSel_One - 1] * 6.3; } |