Quantcast

Documentation Center

  • Trial Software
  • Product Updates

cgsl_0101: Zero-based indexing

ID: Titlecgsl_0101: Zero-based indexing
DescriptionUse zero-based indexing for blocks that require indexing. To set up zero-based indexing, do one of the following:
ASelect block parameter Use zero-based contiguous for the Index Vector block.
BSet block parameter Index mode to Zero-based for the following blocks:
  • Assignment

  • Selector

  • For Iterator

NotesThe C language uses zero-based indexing.
RationaleA, BUse zero-based indexing for compatibility with integrated C code.
A, BResults in more efficient C code execution. One-based indexing requires a subtraction operation in generated code.
See Alsohisl_0021: Consistent vector indexing method
Last ChangedR2011b
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;
}

Was this topic helpful?