性能
模块
MATLAB Function | 将 MATLAB 代码包含在生成可嵌入式 C 代码的模型中 |
函数
coder.inline | 控制生成的代码中特定函数的内联 |
coder.unroll | 通过为每次循环迭代生成循环体的副本来展开 for 循环 |
coder.const | 在生成的代码中将表达式折叠为常量 |
示例和操作指南
- 展开 for 循环和 parfor 循环
控制循环展开。
- 内联代码
内联通过用函数体替换函数调用消除了函数调用的开销。
- Avoid Data Copies of Function Inputs in Generated Code
Generate code that passes input arguments by reference.
- Generate Reusable Code
To reuse functions, save them in files or integrate external functions into generated code.
- Control Run-Time Checks
Improve performance by disabling run-time checks.
概念
- LAPACK Calls for Linear Algebra in a MATLAB Function Block
LAPACK function calls improve the simulation speed of MATLAB Function block algorithms that call certain linear algebra functions.
- BLAS Calls for Matrix Operations in a MATLAB Function Block
BLAS function calls improve the simulation speed of MATLAB Function block algorithms that call certain low-level vector and matrix functions.
- FFTW calls for fast Fourier transform functions in a MATLAB Function Block
FFTW function calls improve the simulation speed of MATLAB Function block algorithms that call MATLAB® fast Fourier transform (FFT) functions.