Main Content
Data Representation in Generated Code
Customize data representation to ease integration with external code and
support interactivity and instrumentation
Signals, states, and block parameters that you create in a model appear in the generated code as variables. Control the way that the code declares and defines these variables.
Generate efficient code by reducing memory usage and specifying numeric data types.
Manage access to signal data and specify parameter tunability.
Package signal and parameter data into structures.
Topics
Storage in the Generated Code
- How Generated Code Stores Internal Signal, State, and Parameter Data
To calculate output data from input data, the generated code must store some internal data in memory, such as block state data and nonscalar parameter data. - Data Structures in the Generated Code
The code generator uses data structures in the generated code to describe the model fully and store data, such as signal and states. - Data Stores in Generated Code
Use a data store to explicitly model a piece of shared global data in the generated code. - Parameter Data Types in the Generated Code
Optimize the generated code and generate code for specific processors by controlling the data types that store parameter data in computer memory. - Share Data Between Code Generated from Simulink, Stateflow, and MATLAB
Define data shared between Simulink, Stateflow, and MATLAB.
Array Layout
- Code Generation of Matrices and Arrays
Work with code that the code generator produces for matrices and arrays. - Generate Row-Major Code for S-Functions
Enable existing S-functions for row-major code generation by specifying the array layout. - Generate Row-Major Code for Model That Contains a MATLAB Function Block
Usecoder.rowMajor
inside the MATLAB Function block to generate row-major code. - Column-Major Layout to Row-Major Layout Conversion of Models with Lookup Table Blocks
Convert existing column-major model to row-major for code generation. - Row-Major Algorithms for Row-Major Array Layout
Generate code by using the row-major and column-major algorithms for row-major array layout. - Interpolation Algorithm for Row-Major Array Layout
Simulate and generate code by using the interpolation algorithm for row-major and column-major array layout. - Interpolation with Subtable Selection Algorithm for Row-Major Array Layout
Simulate and generate code by using the interpolation with subtable selection algorithm for row-major and column-major array layout. - Direct Lookup Table Algorithm for Row-Major Array Layout
Simulate and generate code by using the Direct Lookup Table algorithm for row-major and column-major array layout.
Variable-Size Data
- Variable-Size Signals in Generated Code
Memory allocation for variable-size signals and variable-size arrays in MATLAB Function blocks. - Use Dynamic Memory Allocation for Unbounded Variable-Size Signals in C++ Code Generation
Generate C++ code that uses dynamic memory allocation for unbounded variable-size signals.
Named and Custom Data Types
- Organize Data into Structures in Generated Code
Create structures of signal, state, and parameter data in the generated code. - Use Enumerated Data in Generated Code
Enumerated data is data that is restricted to a finite set of values. Create enumerations in the generated code.