生成代码中的数据表示
自定义数据表示以简化与外部代码的集成并支持交互和插桩
您在模型中创建的信号、状态和模块参数在生成的代码中显示为变量。控制代码声明和定义这些变量的方式。
通过减少内存使用量并指定数值数据类型,生成高效的代码。控制数据类型的命名、定义和用法。
通过为声明和定义指定标识符和文件位置,简化将生成的代码与您自己的代码进行集成的过程。
管理对信号数据的访问并指定参数可调性。
将信号和参数数据封装到结构体中。
提高代码的可读性和可追溯性。
主题
生成的代码中的存储
- 生成的代码如何存储内部信号、状态和参数数据
为了根据输入数据计算输出数据,生成的代码必须在内存中存储一些内部数据,例如模块状态数据和非标量参数数据。 - 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. - Generate Local Variables with Localizable Storage Class
For signals, if possible, generate variables that are local to functions rather than in global storage. - Share Data Between Code Generated from Simulink, Stateflow, and MATLAB
Define data shared between Simulink, Stateflow, and MATLAB. - Air-Fuel Ratio Control System with Fixed-Point Data
Optimize the code generated for an air-fuel ratio control system by using fixed-point data types. - Finely Control Data Representation by Writing TLC Code for a Storage Class
For advanced control of data representation in the generated code, create custom storage classes by writing TLC code.
数组布局
- 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.rowMajorinside 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. - Dimension Preservation of Multidimensional Arrays
Preserve dimensions of multidimensional arrays in generated code. - Preserve Dimensions of Multidimensional Arrays in Generated Code
Preserve array dimensions for model data elements. - 在生成的代码中保留总线元素的维度
保留总线元素的数组维度。
可变大小数据
- 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. - Generate C++ Code for Export-Function Models That Process Unbounded Variable-Size Data
Generate C++ code from an export-function model that processes unbounded variable-size data and integrate the generated code with custom code.
已指定和自定义数据类型
- Manage Replacement of Simulink Data Types in Generated Code
Control the names of primitive, structure, and enumerated data types in the generated code. - Organize Data into Structures in Generated Code
Create structures of signal, state, and parameter data in the generated code. - 在生成的代码中使用枚举数据
枚举数据是指仅限于一组有限值的数据。在生成的代码中创建枚举。 - Control File Placement of Custom Data Types
Integrate the generated code with your own code by placingtypedefstatements in generated and imported files. - Specify Boolean and Data Type Limit Identifiers
Integrate the generated code with your code by specifying the identifiers that correspond to Booleanfalseandtrue. Also, specify the identifiers that correspond to data type limits, which the generated code uses to determine overflows.
