MATLAB-Coder

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen
Abb. 1: MATrix LABoratory (MATLAB®)
Autor: Prof. Dr.-Ing. Schneider

Code Generation Requirements

The three most common code generation issues are solved with these preparation steps:

  1. Define function input variables.
  2. Preallocate arrays before indexing.
  3. Verify MATLAB Coder support.

To see what functions are supported for code generation, you can filter by C/C++ code generation in the documentation. Use the navigation on the left to find supported functions for different toolboxes.

MEX Functions

There are two main reasons you might want a MEX function. You can use MEX functions:

  1. in a test script to verify the generated code
  2. to accelerate your MATLAB algorithms

The acceleration workflow is very similar to the C/C++ source code generation workflow.

Variable Size Inputs

When generating C code from MATLAB functions, you need to specify the size, type, and complexity of the function inputs. For more adaptable functions, you can create type variables, balancing between flexibility and performance.

  • Fixed size inputs only accept one input type but have the best performance.
  • Unbounded dimensions offer maximum flexibility but lower performance.
  • Defining an upper limit for array dimensions improves efficiency.

Nützliche Artikel