Main Content

Data Definition for Code Generation

To generate efficient standalone code, you must define the following types and classes of data differently than you normally would when running your code in MATLAB®.

DataWhat Is DifferentMore Information
ArraysMaximum number of elements is restrictedArray Size Restrictions for Code Generation
Complex numbers
  • Complexity of variables must be set at time of assignment and before first use

  • Expressions containing a complex number or variable evaluate to a complex result, even if the result is zero


Because MATLAB does not support complex integer arithmetic, you cannot generate code for functions that use complex integer arithmetic

Code Generation for Complex Data
CharactersRestricted to 8 bits of precisionEncoding of Characters in Code Generation
Enumerated data
  • Supports integer-based enumerated types only

  • Restricted use in switch statements and for-loops

Function handles
  • Using the same bound variable to reference different function handles can cause a compile-time error.

  • Cannot pass function handles to or from primary or extrinsic functions

  • Cannot view function handles from the debugger

Function Handles