Main Content

Array Layout

Column-major and row-major order for array storage

Array layout refers to the order in which array elements are stored in memory. By default, Simulink® uses column-major layout. In a MATLAB Function block, you can use row-major. Row-major layout can improve performance for certain algorithms and ease integration with external code or data that uses row-major. Linear indexing operations always use column-major layout.

Functions

coder.cevalCall external C/C++ function
coder.columnMajorSpecify column-major array layout for a function or class
coder.rowMajorSpecify row-major array layout for a function or class
coder.isRowMajorDetermine whether the current function or variable uses row-major layout
coder.isColumnMajorDetermine whether the current function or variable uses column-major layout
coder.rowMajorSpecify row-major array layout for a function or class

Topics

Interface with Row-Major Data in MATLAB Function Block

Use row-major layout for C/C++ code generation and external C code integration.

Specify Array Layout in Functions and Classes

Combine different array layouts in a single code project.

Code Design for Row-Major Array Layout

Design your code for efficient use of array layout.