Optimize and Deploy Generated Code
In this step, you learn about how to optimize and deploy the generated code.
Optimization
When you generate standalone code or an accelerated MEX function from your MATLAB® code, the code generator uses a variety of techniques to produce optimized code, including:
Constant folding
Fusion of successive loops
Fusion of successive matrix operations
Elimination of unreachable code.
See MATLAB Coder Optimizations in Generated Code.
Depending on your MATLAB code and your application goals, you can employ various strategies to further improve the speed or memory usage of the generated code, such as:
Using parallel
for-loops (parfor)Unrolling
for-loops andparfor-loopsMinimizing dynamic memory allocation
Forcing function inlining
Using BLAS, LAPACK, and FFTW libraries
Disabling support for nonfinite numbers and integer overflow
Maximizing stack usage
Reusing large arrays and structures
For details of these and other strategies, see Optimize Generated C/C++ and MEX Code.
Deployment
After you verify that the generated code behaves according to your requirements, you can deploy it. After you generate standalone code, you can:
Create a standalone C or C++ executable and deploy this application on a target platform. For an example, see Generate C++ Executable at the Command Line.
Integrate the generated source code or library into an existing C or C++ project. For an example, see Use a Dynamic Library in a Microsoft Visual Studio Project.
Run the generated code on embedded microprocessors by using a toolchain. For an example, see Build 32-bit DLL on 64-bit Windows Platform Using MSVC Toolchain.
Deploy the generated code on external hardware. For examples, see Deploy Generated C Code to External Hardware: Raspberry Pi Examples.
Package the generated code for transfer to another development environment. See Package Code for Other Development Environments.