Main Content


Convert numeric array to MATLAB object for C++ array



cArray = clibConvertArray(typeName,A) converts MATLAB® array A to a C++ object of type typeName. The dimensions of cArray are the same as A. Each element of cArray is initialized by the corresponding element of A.

The memory of cArray is owned by MATLAB. To release the memory, call clibRelease.


collapse all

Suppose that you have an interface to a C++ library libname. Convert a MATLAB array of double.

a = [1 2 3 4];
arr = clibConvertArray('clib.libname.Double', a);

Input Arguments

collapse all

C++ type, specified as a string or a character vector. Supported types are:

  • Floating point types

  • Integer types

  • Boolean types

Character types are not supported except for the char type which is represented as an integer type.

C++ class names and void types are not supported.

MATLAB converts the names of fundamental C++ types to upper camel case. For example, typeName for C++ type signed int is SignedInt.

The type is a fully qualified C++ type name. For example, if a library libname defines a class myclass, then typeName is clib.libname.myclass.

Example: clib.libname.Double

Data Types: char | string

MATLAB array, specified as numeric MATLAB type.

Introduced in R2020a