Convert MATLAB Types to COM Types
Data types for the arguments and return values of the server functions are expressed
as Automation data types, which are language-independent types defined by the Automation
protocol. For example, BSTR is a wide-character string type defined
as an Automation type, and is the same data format used by the Visual Basic® language to store strings. Any COM-compliant client should support these
data types, although the details of how you declare and manipulate these types are
client specific.
This table shows how MATLAB® converts data from MATLAB to COM types.
| MATLAB Type | Closest COM Type | Allowed Types |
|---|---|---|
| handle | VT_DISPATCHVT_UNKNOWN | VT_DISPATCHVT_UNKNOWN |
| character vector |
VT_BSTR | VT_LPWSTRVT_LPSTRVT_BSTRVT_FILETIMEVT_ERRORVT_DECIMALVT_CLSIDVT_DATE |
int16 |
VT_I2 | VT_I2 |
uint16 | VT_UI2 | VT_UI2 |
int32 | VT_I4 | VT_I4VT_INT |
uint32 | VT_UI4 | VT_UI4VT_UINT |
int64 | VT_I8 | VT_I8 |
uint64 | VT_UI8 | VT_UI8 |
single | VT_R4 | VT_R4 |
double |
VT_R8 | VT_R8VT_CY
|
logical | VT_BOOL
| VT_BOOL |
| char |
VT_I1 | VT_I1VT_UI1 |
Variant Data
variant is any data type except a structure or a sparse array.
(For more information, see Fundamental MATLAB Classes.)
When used as an input argument, MATLAB treats variant and
variant( the same
way.pointer)
If you pass an empty array ([]) of type
double, MATLAB creates a
variant( set to
pointer)VT_EMPTY. Passing an empty array of any other numeric type is
not supported.
| MATLAB Argument | Closest COM Type | Allowed Types |
|---|---|---|
variant |
VT_VARIANT | VT_VARIANTVT_USERDEFINEDVT_ARRAY |
variant( | VT_VARIANT | VT_VARIANT |
VT_BYREF |
SAFEARRAY Data
When a COM method identifies a SAFEARRAY or
SAFEARRAY(pointer), the MATLAB equivalent is a matrix.
| MATLAB Argument | Closest COM Type | Allowed Types |
|---|---|---|
SAFEARRAY | VT_SAFEARRAY | VT_SAFEARRAY |
SAFEARRAY(pointer) |
VT_SAFEARRAY | VT_SAFEARRAY |
VT_BYREF |
VT_DATE Data Type
To pass a VT_DATE type input to a Visual Basic program, use the MATLAB class COM.date. For example:
d = COM.date(2005,12,21,15,30,05);
get(d)
Value: 7.3267e+005
String: '12/21/2005 3:30:05 PM'Use the now function to set the Value
property to a date number:
d.Value = now;
COM.date accepts the same input arguments as datenum.
Unsupported Types
MATLAB does not support these COM types.
String array
Structure
Sparse array
Multidimensional
SAFEARRAYs (greater than two dimensions)Write-only properties