Data Copy Reduction
Reduce RAM and ROM consumption and increase code execution speed by eliminating data copies in the generated code. The code generator eliminates some data copies. You can eliminate other data copies by adjusting certain model parameter settings, specifying the same name for the input and output arguments of MATLAB Function blocks, and by using Simulink signals to specify reuses.
Topics
- Minimize Computations and Storage for Intermediate Results at Block OutputsThe code generator folds block computations into a single expression, instead of generating separate code statements and storage declarations for each block in a model. 
- Fold ExpressionsExpression fold code to minimize the computation of intermediate results at block outputs and the storage of such results in temporary buffers or variables. 
- Enable and Reuse Local Block Outputs in Generated CodeWhere possible, the code generator declares block outputs as local variables, so that it can potentially reuse these variables. 
- Generate Efficient Code for BusesModel buses to maximize efficiency of the generated code. 
- Inline Invariant SignalsUse the numerical values of invariant signals instead of their symbolic names in the generated code. 
- Use memcpy Function to Optimize Generated Code for Vector AssignmentsThe code generator optimizes the generated code for vector assignments by replacing forloops withmemcpyfunction calls.
- Control Inlining to Fine-Tune Performance and Readability of Generated CodeInlining eliminates the overhead of function calls but can produce larger C/C++ code and reduce code readability.