Main Content

MATLABLanguage Features Supported for Single-Precision Conversion

MATLABLanguage Features Supported for Single-Precision Conversion

Single-precision conversion supports the following MATLAB®language features:

  • N-dimensional arrays.

  • Matrix operations, including deletion of rows and columns.

  • Variable-size data(seeGenerate Code for Variable-Size Data). Comparison plotting does not support variable-size data.

  • Subscripting (seeIncompatibility with MATLAB in Matrix Indexing Operations for Code Generation).

  • Complex numbers (seeCode Generation for Complex Data).

  • Numeric classes (seeSupported Variable Types).

  • Program control statementsif,switch,for,while, andbreak.

  • Arithmetic, relational, and logical operators.

  • Local functions.

  • Global variables.

  • Persistent variables.

  • Structures.

  • Characters.

    Single-precision conversion does not support the complete set of Unicode®characters. Characters are restricted to 8 bits of precision in generated code. Many mathematical operations require more than 8 bits of precision. If you intend to convert your MATLAB algorithm to single precision, it is a best practice not to perform arithmetic with characters.

  • MATLAB classes. Single-precision conversion supports:

    • Class properties

    • Constructors

    • Methods

    • Specializations

    It does not support class inheritance or packages.

    Single-precision conversion usingcodegenwith the-singleCoption does not support classes when the properties have default values. Property values must be initialized in the constructor. Constant properties cannot be initialized to double precision data types.

  • Function calls (seeResolution of Function Calls for Code Generation)

  • vararginandvarargoutare supported when you generate single-precision C/C++ code by using theMATLAB Coder™app orcodegenwith-singleC. They are not supported when you usecodegenwith-double2single.

    For functions that do not usevararginorvarargout, you can control the number of input or output arguments in the generated entry-point function only if you generate single-precision C/C++ code by using theMATLAB Coderapp orcodegenwith-singleC.

MATLABLanguage Features Not Supported for Single-Precision Conversion

Single-precision conversion does not support the following features:

  • Anonymous functions

  • Cell arrays

  • String scalars

  • Objects of value classes as entry-point function inputs or outputs

  • Function handles

  • Java®

  • Nested functions

  • Recursion

  • Sparse matrices

  • try/catchstatements

  • vararginandvarargout, or generation of fewer input or output arguments than an entry-point function defines