clibArray

Create MATLAB object for C++ array or std::vector

Description

example

cArray = clibArray(typeName,dimensions) creates a MATLAB® object representing a C++ object of typeName with C++ dimensions specified as [x1,...,xN]. If the C++ object is a primitive type, then cArray contains zero values. If the C++ object is a class-type, then MATLAB initializes cArray using the default constructor.

A MATLAB clib array can be defined only when the corresponding C++ native array or std::vector is used by supported C++ constructs — function arguments, function returns, and data members.

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

To convert a MATLAB array to a C++ array, call clibConvertArray.

Examples

collapse all

Suppose that you have a library libname with a class myclass.

myclassArray = clibArray('clib.libname.myclass',5);
class(myclassArray)
ans = 
    'clib.array.libname.myclass' 

Input Arguments

collapse all

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

  • Floating point types

  • Integer types

  • Boolean types

  • User-defined C++ types

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

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

The number of elements in each dimension of the array, specified as integers [x1,...,xN].

Example: [2,3]

Introduced in R2020a