Pass clib.array
to C++ Functions
MATLAB® provides the clib.array
interface to wrap C++ native
arrays and std::vector
types in MATLAB objects. The term clib array refers to the
MATLAB object representation of these C++ types.
A MATLAB clib array is defined only when the corresponding C++ native array or
std::vector
type is used by supported C++ constructs—function
input and output arguments and data members. The library header files must contain the
definition of the array element type. The constructs must be supported by MATLAB and included when building the MATLAB interface to the C++ library.
For information about creating a MATLAB array of C++ objects or converting an MATLAB array to a C++ array object, see Create MATLAB Array of C++ Objects.
MATLAB C++ Object Array Properties
MATLAB arrays created with clibArray
or clibConvertArray
have these properties.
Property | Type | Access | Description |
---|---|---|---|
| double vector | Read-only | Dimensions of the C++ array. For example, |
| logical scalar | Read-only |
|
MATLAB C++ Object Array Methods
MATLAB arrays created with clibArray
or
clibConvertArray
have these methods.
Method | Syntax | Description |
---|---|---|
| append([element]) | Add an optionally specified element to the end of the array. For a primitive MATLAB clib array, if you do not specify an input argument, then the method appends a zero value. For a class-type MATLAB clib array, if you do not specify an input argument, then the method appends an object created by the class-type default constructor. If the class-type default constructor is deleted, a run-time error occurs. |
| removeLast | Remove the last element of the array. If the MATLAB clib array is empty, a run-time error occurs. |
| double | Convert to double precision. |
|
| Convert to |
|
| Convert to |
|
| Convert to |
|
| Convert to |
|
| Convert to |
|
| Convert to |
|
| Convert to |
|
| Convert to |
| logical | Convert to |
| struct | Convert to structure. |
Memory Management
The memory for MATLAB arrays created with clibArray
or
clibConvertArray
is managed by
MATLAB. You do not need to explicitly release the memory for clib arrays. For
more information about releasing memory for C++ objects from MATLAB, see clibRelease
.