Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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?