Use Row-Major Algorithms for Lookup Table Blocks
R2026bWhen you approximate nonlinear systems using Lookup Table blocks, you often need to generate C/C++ code from those models. In Simulink®, to generate C/C++ code from models, you can use either Simulink Coder™ or Embedded Coder®.
You can generate the code for real-time and non-real-time applications using Simulink Coder, including simulation acceleration, rapid prototyping, and hardware-in-the-loop testing. For more information, see Generate Code Using Simulink Coder (Simulink Coder).
Embedded Coder extends the capability of Simulink Coder by optimizing code for deployment on rapid-prototyping boards, embedded processors, or microprocessors. For more information, see Generate Code Using Embedded Coder (Embedded Coder).
The accuracy of the generated code depends on the semantics of the lookup tables, and the semantics of look up tables depend on the array layout of the lookup data. You can select array layout for Lookup Table blocks to generate accurate code from the models that contain the Lookup Table blocks.
The Direct Lookup Table (n-D), Interpolation Using Prelookup, and n-D Lookup Table blocks have algorithms that work with row-major array layouts or column-major array layouts. This capability requires a Simulink Coder license.
Prior to R2018b, lookup table blocks supported only column-major array layouts. When selecting algorithms optimized for a row-major array layout for a model previously configured for algorithms optimized for a column-major array layout, you might need to preserve lookup table block semantics. For example, consider a model with these Lookup Table blocks and configurations:
An Interpolation Using Prelookup block configured with a subtable selection before interpolation
A Direct Lookup Table (n-D) configured for a vector or 2-D matrix output
You can use the permute function to rearrange the
dimensions of the array and preserve the semantics. For an example of preserving
semantics by using table permutations, see Direct Lookup Table Algorithm for Row-Major Array Layout (Simulink Coder).
For more information on array layouts, see Code Generation of Matrices and Arrays (Simulink Coder).
See Also
1-D Lookup Table | 2-D Lookup Table | n-D Lookup Table | Direct Lookup Table (n-D) | Interpolation Using Prelookup