Array layout refers to the order in which array elements are stored in memory. By default, MATLAB® Coder™ generates code that uses column-major layout. You can also generate code that uses 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 in generated code.
codegen | Generate C/C++ code from MATLAB code |
coder.ceval | Call external C/C++ function |
coder.columnMajor | Specify column-major array layout for a function or class |
coder.isColumnMajor | Determine whether the current function or variable uses column-major layout |
coder.isRowMajor | Determine whether the current function or variable uses row-major layout |
coder.rowMajor | Specify row-major array layout for a function or class |
coder.CodeConfig | Configuration parameters for C/C++ code generation from MATLAB code |
coder.MexCodeConfig | Configuration parameters for MEX function generation from MATLAB code |
coder.EmbeddedCodeConfig | Configuration parameters for C/C++ code generation from MATLAB code with Embedded Coder |
Row-Major and Column-Major Array Layouts
Understand how MATLAB stores array elements in memory.
Generate Code That Uses Row-Major Array Layout
Generate C/C++ code with row elements stored contiguously in memory.
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.