Main Content

clibConvertArray

Convert numeric MATLAB array to array of C++ objects

Since R2020a

Description

example

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

Like clibArray, you can only construct an array if the library requires that type.

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

Examples

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);
class(arr)
'clib.array.libname.Double'

Input Arguments

collapse all

C++ type, specified as a string or a character vector. For more information, see C++ to MATLAB Data Type Mapping. Supported types are:

MATLAB converts the names of fundamental C++ types to upper camel case. For example, elementTypeName 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 elementTypeName is clib.libname.myclass.

C++ class names are not supported.

Example: clib.libname.Double

Data Types: char | string

MATLAB array, specified as numeric MATLAB type.

Version History

Introduced in R2020a