View
31
Download
0
Category
Preview:
Citation preview
MATLABreg
CC++ Fortran Java and Python APIReference
R2017b
How to Contact MathWorks
Latest news wwwmathworkscom
Sales and services wwwmathworkscomsales_and_services
User community wwwmathworkscommatlabcentral
Technical support wwwmathworkscomsupportcontact_us
Phone 508-647-7000
The MathWorks Inc3 Apple Hill DriveNatick MA 01760-2098
MATLABreg CC++ Fortran Javareg and Pythonreg API Referencecopy COPYRIGHT 1984ndash2017 by The MathWorks IncThe software described in this document is furnished under a license agreement The software may beused or copied only under the terms of the license agreement No part of this manual may be photocopiedor reproduced in any form without prior written consent from The MathWorks IncFEDERAL ACQUISITION This provision applies to all acquisitions of the Program and Documentationby for or through the federal government of the United States By accepting delivery of the Program orDocumentation the government hereby agrees that this software or documentation qualifies ascommercial computer software or commercial computer software documentation as such terms are used ordefined in FAR 12212 DFARS Part 22772 and DFARS 252227-7014 Accordingly the terms andconditions of this Agreement and only those rights specified in this Agreement shall pertain to and governthe use modification reproduction release performance display and disclosure of the Program andDocumentation by the federal government (or other entity acquiring for or through the federalgovernment) and shall supersede any conflicting contractual terms or conditions If this License fails tomeet the governments needs or is inconsistent in any respect with federal procurement law thegovernment agrees to return the Program and Documentation unused to The MathWorks IncTrademarks
MATLAB and Simulink are registered trademarks of The MathWorks Inc Seewwwmathworkscomtrademarks for a list of additional trademarks Other product or brandnames may be trademarks or registered trademarks of their respective holdersPatents
MathWorks products are protected by one or more US patents Please seewwwmathworkscompatents for more information
Revision HistoryDecember 1996 First Printing New for MATLAB 5 (Release 8)May 1997 Online only Revised for MATLAB 51 (Release 9)January 1998 Online Only Revised for MATLAB 52 (Release 10)January 1999 Online Only Revised for MATLAB 53 (Release 11)September 2000 Online Only Revised for MATLAB 60 (Release 12)June 2001 Online only Revised for MATLAB 61 (Release 121)July 2002 Online only Revised for MATLAB 65 (Release 13)January 2003 Online only Revised for MATLAB 651 (Release 13SP1)June 2004 Online only Revised for MATLAB 70 (Release 14)October 2004 Online only Revised for MATLAB 701 (Release 14SP1)March 2005 Online only Revised for MATLAB 704 (Release 14SP2)September 2005 Online only Revised for MATLAB 71 (Release 14SP3)March 2006 Online only Revised for MATLAB 72 (Release 2006a)September 2006 Online only Revised for MATLAB 73 (Release 2006b)March 2007 Online only Revised and renamed for MATLAB 74
(Release 2007a)September 2007 Online only Revised and renamed for MATLAB 75
(Release 2007b)March 2008 Online only Revised and renamed for MATLAB 76
(Release 2008a)October 2008 Online only Revised and renamed for MATLAB 77
(Release 2008b)March 2009 Online only Revised for MATLAB 78 (Release 2009a)September 2009 Online only Revised for MATLAB 79 (Release 2009b)March 2010 Online only Revised and renamed for MATLAB 710
(Release 2010a)September 2010 Online only Revised for MATLAB 711 (Release 2010b)April 2011 Online only Revised for MATLAB 712 (Release 2011a)September 2011 Online only Revised for MATLAB 713 (Release 2011b)March 2012 Online only Revised for MATLAB 714 (Release 2012a)September 2012 Online only Revised for MATLAB 80 (Release 2012b)March 2013 Online only Revised for MATLAB 81 (Release 2013a)September 2013 Online only Revised for MATLAB 82 (Release 2013b)March 2014 Online only Revised for MATLAB 83 (Release 2014a)October 2014 Online only Revised for MATLAB 84 (Release 2014b)March 2015 Online only Revised for MATLAB 85 (Release 2015a)September 2015 Online only Revised for MATLAB 86 (Release 2015b)March 2016 Online only Revised for MATLAB 90 (Release 2016a)September 2016 Online only Revised for MATLAB 91 (Release 2016b)March 2017 Online only Revised for MATLAB 92 (Release 2017a)September 2017 Online only Revised for MATLAB 93 (Release 2017b)
API Reference1
v
Contents
API Reference
1
matlabdataArrayDimensionsType specifying array dimensions
DescriptionUse the ArrayDimensions type to specify the size of an array ArrayDimensions isspecified as
using ArrayDimensions = stdvectorltsize_tgt
Free Function
getNumElementsinline size_t getNumElements(const ArrayDimensionsamp dims)
Determine the number of elements based on the ArrayDimensions
const ArrayDimensionsampdims
Array dimensions
inline size_t Number of elements
None
See Also
TopicsldquoMATLAB Data API Typesrdquo
1 API Reference
1-2
Introduced in R2017b
matlabdataArrayDimensions
1-3
matlabdataArrayElementRefC++ class representing element of Array or ReferenceltArraygt object
DescriptionAn ArrayElementRef object is created when using operator[] into an Array or aReferenceltArraygt It is untyped since Array and ReferenceltArraygt do not havetype information It collects up the indexes specified by the user and can be cast to anelement if the array holds primitive data or can be used to create a ReferenceltTgtinstance
Indexing is zero-based
Class DetailsNamespace matlabdataInclude ArrayElementRefhpp
Template Parametersbool is_const_ref Indicates if this reference is const The non-const
version of this class supports assignment
Other Operatorsbull ldquooperator[]rdquo on page 1-4bull ldquooperator Trdquo on page 1-5bull ldquooperator=rdquo on page 1-6
operator[]ArrayElementRefltis_const_refgt operator[](size_t idx)
ArrayElementRefltis_const_refgt operator[](stdstring idx)
1 API Reference
1-4
Add an index to an Array
size_t idx Index to add Call this syntax to use two or more indices in anindexing operation
stdstring idx Index to add Array must support string indexing
TooManyIndicesProvidedException
Too many indices provided The number of size_tindices is more than the number of dimensions in thearray
StringIndexMustBeLastException
String index is not the last index A size_t index isprovided after a string index
StringIndexNotValidException
An stdstring index is not valid for this array
CanOnlyUseOneStringIndexException
More than one stdstring index provided
double val = arr[2][7][f1]
operator Ttemplate lttypename Tgtoperator T() const
Cast a value Throws an error if not arithmetic complex or stdstring
InvalidArrayIndexException
The index provided is not valid for this Array or one of theindices is out of range
TypeMismatchException
The element of the Array does not contain the type specifiedby T
Array dblArray_const = factorycreateArrayltdoublegt(22)double val = dblArray_const[1][2]
matlabdataArrayElementRef
1-5
operator=template lttypename TgtArrayElementRefltis_const_refgtamp operator= (T rhs)
Assign a primitive or complex type to an element of an Array The Array must be non-const
If the Array contains other Arrays then operator= can assign an Array into theelement
T rhs The value to assign to an element in the Array specifiedas a primitive or complex type or as an Array
ArrayElementRefltis_const_refgtamp
Reference to the Array element
InvalidArrayIndexException
The index provided is not valid for this Array or one of theindices is out of range
TypeMismatchException
The element of the Array does not contain a primitive orcomplex type or does not contain other Arrays
Assign numeric types to Array arr
Array arr = factorycreateArrayltdoublegt(22)arr[0][0] = 55arr[1][2] = stdcomplexltdoublegt(54 31)
Assign an Array to cell_arr then create a ReferenceltArraygt ref to the element
Array cell_arr = factorycreateArrayltArraygt(13)cell_arr[2] = factorycreateScalar(true)ReferenceltArraygt ref = cell_arr[2]
See AlsoArray | ArrayElementTypedRef | Reference | TypedArrayRef
1 API Reference
1-6
Introduced in R2017b
matlabdataArrayElementRef
1-7
matlabdataArrayElementTypedRefC++ class representing element of TypedArray or TypedArrayRef object
DescriptionAn ArrayElementTypedRef object is created when using operator[] into aTypedArrayltTgt or a TypedArrayRefltTgt It collects up the indexes specified by theuser and can be cast to ltTgt without the added cost of type checking that exists whenusing ArrayElementRef Primitive types can be cast to Tamp which is not supported withArrayElementRef The non-const version of this class supports assignment
Class DetailsNamespace matlabdataInclude ArrayElementTypedRefhpp
Template ParametersT Element typesbool is_const_ref TBD
Other Operatorsbull ldquooperator[]rdquo on page 1-8bull ldquooperator referencerdquo on page 1-9bull ldquooperator=rdquo on page 1-10
operator[]ArrayElementTypedRefltT is_const_refgt operator[](size_t idx)
ArrayElementTypedRefltArray is_const_refgt operator[](stdstringidx)
1 API Reference
1-8
Add an index to an Array
size_t idx Index to add Call this syntax to use two or more indicesin an indexing operation
stdstring idx Index to add Array must support string indexing
ArrayElementTypedRefltArray is_const_refgt
New instance with the additional index
TooManyIndicesProvidedException
Too many indices provided
StringIndexMustBeLastException
String index is not the last index
double val = arr[2][7][3]
operator referenceoperator reference() const
operator stdstring() const
Cast to reference to its primitive value
T
stdstring
The value
InvalidArrayIndexException
The index provided is not valid for this Array or one of theindices is out of range
TypeMismatchException
The element of the Array cannot be cast to stdstring
double val = dblArray[1][2]
stdstring val = strArray[1][2]
matlabdataArrayElementTypedRef
1-9
operator=ArrayElementTypedRefltT is_const_refgtamp operator= (T rhs)
ArrayElementTypedRefltT is_const_refgtamp operator= (stdstring rhs)
Assign a value into an Array The Array must be non-const
T rhs
stdstring rhs
Value to assign to an element in the Array
ArrayElementTypedRefltTis_const_refgtamp
Reference to the Array element
InvalidArrayIndexException
The index provided is not valid for this Array or one of theindices is out of range
TypeMismatchException
The element of the Array cannot be cast to stdstring
arr[1][2] = stdcomplexltdoublegt(54 31)
arr[1][2] = MyString
ExamplesTBD
TypedArrayltdoublegt arr = factorycreateArrayltdoublegt(22)arr[0][0] = 55doubleamp val = arr[0][0]CellArray cell_arr = factorycreateArrayltArraygt(12)cell_arr[0] = factorycreateScalar(105)cell_arr[1] = factorycreateScalar(false)ArrayRef ref_to_element = cell_arr[0]TypedArrayRefltdoublegt typed_ref_to_element = cell_arr[0]
1 API Reference
1-10
Array const shared_copy_of_element = cell_arr[1]TypedArrayltboolgt const typed_shared_copy_of_element = cell_arr[1]
See AlsoArray | ArrayElementRef | ArrayElementTypedRef | Reference |TypedArrayRef | TypedIterator
Introduced in R2017b
matlabdataArrayElementTypedRef
1-11
matlabdataArrayFactoryC++ class to create arrays
DescriptionUse ArrayFactory to create matlabdataArray objects
Class DetailsNamespace matlabdataInclude ArrayFactoryhpp
Constructors
Default Constructor
ArrayFactory()
FailedToLoadLibMatlabDataArrayException
Concrete implementation has not been loaded
Destructor~ArrayFactory()
Member Functionsbull ldquocreateArrayrdquo on page 1-13bull ldquocreateScalarrdquo on page 1-14bull ldquocreateCellArrayrdquo on page 1-15
1 API Reference
1-12
bull ldquocreateCharArrayrdquo on page 1-16bull ldquocreateStructArrayrdquo on page 1-17bull ldquocreateEnumArrayrdquo on page 1-18bull ldquocreateSparseArrayrdquo on page 1-19bull ldquocreateEmptyArrayrdquo on page 1-20bull ldquocreateBufferrdquo on page 1-21bull ldquocreateArrayFromBufferrdquo on page 1-21
createArraytemplate lttypename TgtTypedArrayltTgt createArray(ArrayDimensions dims)
template lttypename ItType typename TgtTypedArrayltTgt createArray(ArrayDimensions dims ItType begin ItType end)
template lttypename TgtTypedArrayltTgt createArray(ArrayDimensions dims const T const begin const T const end)
template lttypename Tgt TypedArrayltTgt createArray(ArrayDimensions dims stdinitializer_listltTgt data)
Creates a TypedArrayltTgt with the given dimensions Fills the array with data ifspecified Data is copied and must be in column major order
bull ItType - Iterator types specified as stditeratorbull T - Element types specified as one of the following C++ data types
bool int8_t int16_t int32_t int64_t uint8_tuint16_t uint32_t uint64_t float double char16_t
matlabdataArrayFactory
1-13
matlabdataString
stdcomplexltdoublegt
stdcomplexltfloatgt
stdcomplexltint8_tgt
stdcomplexltuint8_tgt
stdcomplexltint16_tgt
stdcomplexltuint16_tgt
stdcomplexltint32_tgt
stdcomplexltuint32_tgt
stdcomplexltint64_tgt
stdcomplexltuint64_tgt
matlabdataMATLABString
ArrayDimensionsdims
Dimensions for the array
ItType begin
ItType end
Start and end of the user supplied data The data type isdetermined by the value_type of the iterator
const T constbegin
const T const end
Start and end of the user supplied data specified as C-stylepointer Supports all primitive types complex types andstring types
stdinitializer_listltTgt
Initializer list containing the data
matlabOutOfMemoryException
The array could not be allocated
createScalartemplate lttypename TgtTypedArrayltTgt createScalar(const T val)
TypedArrayltStringgt createScalar(const String val)
TypedArrayltStringgt createScalar(const stdstring val)
Creates a scalar TypedArrayltTgt with the given value This method supports arithmetictypes complex types and string types
const T val Value to be inserted into the scalar If valis 7-bit ASCII data then the methodconverts it to UTF16
const String valconst stdstring val
1 API Reference
1-14
matlabOutOfMemoryException
The array could not be allocated
NonAsciiCharInInputDataException
Input is stdstring and contains non-ASCIIcharacters
include MatlabDataArrayhpp
int main() matlabdataArrayFactory factory
Create a vector containing 2 scalar values stdvectorltmatlabdataArraygt args( factorycreateScalarltint16_tgt(100) factorycreateScalarltint16_tgt(60)) return 0
ldquoCall Function with Single Returned Argumentrdquo
createCellArrayCellArrayltArraygt createCellArray(ArrayDimensions dims)
template lttypename TargsgtCellArrayltArraygt createCellArray(ArrayDimensions dims Targs data)
Creates a CellArray with the specified data Data is specified in column major order
Targs Variadic template of
bull arithmetic typebull complex typebull matlabdataStringbull stdstringbull matlabdataArray
matlabdataArrayFactory
1-15
ArrayDimensionsdims
Dimensions of the cell array
Targs data Elements to be inserted into the cell array specified as aprimitive complex type string or Array
matlabOutOfMemoryException
The array could not be allocated
NonAsciiCharInInputDataException
Input is stdstring and contains non-ASCIIcharacters
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory f CellArray myArray = fcreateCellArray( 12 fcreateCharArray(MATLAB Cell Array) fcreateArrayltdoublegt( 22 12 22 32 42 ))
return 0
createCharArrayCharArray createCharArray(String str)
CharArray createCharArray(stdstring str)
Creates a 1xn CharArray from the specified input where n is the string length
matlabdataString str
Data to be filled into the array
stdstring str
matlabOutOfMemoryException
The array could not be allocated
1 API Reference
1-16
NonAsciiCharInInputDataException
Input is stdstring and contains non-ASCIIcharacters
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory CharArray A = factorycreateCharArray(This is a char array) return 0
createStructArrayStructArray createStructArray(ArrayDimensions dims stdvectorltstdstringgt fieldNames)
Creates a StructArray with the given dimensions and field names
ArrayDimensions dims Dimensions for the arraystdvectorltstdstringgtfieldNames
Vector of the field names for the structure
matlabOutOfMemoryException
The array could not be allocated
DuplicateFieldNameInStructArrayException
Duplicate field names specified
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory f
Create StructArray equivalent to MATLAB structure s s = struct(loc east west data [1 2 3] [4 5 6 7 8]) StructArray S = fcreateStructArray( 12 loc data ) S[0][loc] = fcreateCharArray(east) S[0][data] = fcreateArrayltuint8_tgt( 1 3 1 2 3 )
matlabdataArrayFactory
1-17
S[1][loc] = fcreateCharArray(west) S[1][data] = fcreateArrayltdoublegt( 1 5 4 5 6 7 8 )
Access the value defined by the MATLAB statement s(1)data ReferenceltArraygt val = S[0][data] return 0
createEnumArrayEnumArray createEnumArray(ArrayDimensions dims stdstring className stdvectorltstdstringgt enums)
EnumArray createEnumArray(ArrayDimensions dims stdstring className)
Creates an EnumArray of type className If specified the array is initialized with thelist of enumeration names
ArrayDimensionsdims
Dimensions for the array
stdstringclassName
Class name of the enumeration array
stdvectorltstdstringgt enums
List of the enumeration names
matlabOutOfMemoryException
The array could not be allocated
MustSpecifyClassNameException
Class name not specified
WrongNumberOfEnumsSuppliedException
The wrong number of enumerations provided
include MatlabDataArrayhppinclude ltvectorgt
1 API Reference
1-18
int main() using namespace matlabdata ArrayFactory f auto blue = fcreateEnumArray( 11 TextColor Blue )
Create an argument vector stdvectorltArraygt args( fcreateCharArray(My text) stdmove(blue) )
return 0
createSparseArraytemplate lttypename TgtSparseArrayltTgt createSparseArray(ArrayDimensions dims size_t nnz buffer_ptr_tltTgt data buffer_ptr_tltsize_tgt rows buffer_ptr_tltsize_tgt cols)
Creates a SparseArrayltTgt with rows-by-cols dimensions Only two dimensions areallowed for sparse arrays The buffer is not copied and the array takes ownership
T Element types specified as double bool orstdcomplexltdoublegt
ArrayDimensionsdims
Dimensions for the array
size_t nnz Number of nonzero elementsbuffer_ptr_tltTgtdata
Buffer containing the nonzero elements
buffer_ptr_tltsize_tgt rows
Buffer containing the row value for each element
buffer_ptr_tltsize_tgt cols
Buffer containing the column value for each element
matlabdataArrayFactory
1-19
matlabOutOfMemoryException
The array could not be allocated
InvalidDimensionsInSparseArrayException
More than two dimensions are specified
include MatlabDataArrayhpp
int main() stdvectorltdoublegt data = 35 1298 2176 stdvectorltsize_tgt rows = 001 stdvectorltsize_tgt cols = 048 size_t nnz = 3
matlabdataArrayFactory factory auto data_p = factorycreateBufferltdoublegt(nnz) auto rows_p = factorycreateBufferltsize_tgt(nnz) auto cols_p = factorycreateBufferltsize_tgt(nnz)
double dataPtr = data_pget() size_t rowsPtr = rows_pget() size_t colsPtr = cols_pget() stdfor_each(databegin() dataend() [amp](const doubleamp e) (dataPtr++) = e ) stdfor_each(rowsbegin() rowsend() [amp](const size_tamp e) (rowsPtr++) = e ) stdfor_each(colsbegin() colsend() [amp](const size_tamp e) (colsPtr++) = e )
matlabdataSparseArrayltdoublegt arr = factorycreateSparseArrayltdoublegt( 29 nnz stdmove(data_p) stdmove(rows_p) stdmove(cols_p)) return 0
createEmptyArrayArray createEmptyArray()
Creates an empty Array containing no elements
Array Empty array
1 API Reference
1-20
matlabOutOfMemoryException
The array could not be allocated
createBuffertemplate lttypename Tgtbuffer_ptr_tltTgt createBuffer(size_t numberOfElements)
Creates a buffer which can be passed into createArrayFromBuffer No data copies aremade when creating an array from a buffer Data must be in column major order
T Primitive types
size_t numberOfElements Number of elements not the actualbuffer size
buffer_ptr_tltTgt Unique_ptr containing the buffer
matlabOutOfMemoryException
The array could not be allocated
createArrayFromBuffertemplate lttypename TgtTypedArrayltTgt createArrayFromBuffer(ArrayDimensions dims buffer_ptr_tltTgt buffer)
Creates a TypedArrayltTgt using the given buffer
T Primitive types
ArrayDimensions dims Dimensions for the arraybuffer_ptr_tltTgt buffer Buffer containing the data The buffer is not
copied The TypedArrayltTgt object takesownership of the buffer Data must be in columnmajor order
matlabdataArrayFactory
1-21
matlabOutOfMemoryException
The array could not be allocated
See Also
Introduced in R2017b
1 API Reference
1-22
matlabdataReferenceltArraygtC++ class to get reference to Array
DescriptionUse the ReferenceltArraygt class to get a reference to an Array element of a containerobject such as a MATLAB structure or cell array The class is a base class for allreference types that refer to arrays and provides basic array information ArrayRef isdefined as
using ArrayRef = ReferenceltArraygt
Class DetailsNamespace matlabdataInclude ArrayReferenceExthpp
Member Functionsbull ldquogetTyperdquo on page 1-23bull ldquogetDimensionsrdquo on page 1-24bull ldquogetNumberOfElementsrdquo on page 1-24bull ldquoisEmptyrdquo on page 1-24
getTypeArrayType getType() const
ArrayType Type of the array
NotEnoughIndicesProvidedException
Not enough indices provided
matlabdataReferenceltArraygt
1-23
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
InvalidArrayTypeException
Array type not recognized
getDimensionsArrayDimensions getDimensions() const
ArrayDimensions Array dimensions vector
NotEnoughIndicesProvidedException
Not enough indices provided
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
getNumberOfElementssize_t getNumberOfElements() const
size_t Number of elements in array
NotEnoughIndicesProvidedException
Not enough indices provided
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
isEmptybool isEmpty() const
bool Returns true if array is empty otherwise returns false
NotEnoughIndicesProvidedException
Not enough indices provided
1 API Reference
1-24
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
Free Functionsbull ldquogetReadOnlyElementsrdquo on page 1-25bull ldquogetWritableElementsrdquo on page 1-25
getReadOnlyElementstemplate lttypename TgtRangeltTypedIterator T constgt getReadOnlyElements(const ReferenceltArraygtamp ref)
Get a range containing the elements of the Array or ReferenceltArraygt Iteratorscontained in the range are const
const ReferenceltArraygtampref
ReferenceltArraygt
RangeltTypedIterator Tconstgt
Range containing begin and end iterators for theelements of the input ReferenceltArraygt
InvalidArrayTypeException
Array does not contain type T
getWritableElementstemplate lttypename TgtRangeltTypedIterator Tgt getWritableElements(ReferenceltArraygtamp ref)
Get a range containing the elements of the Array or ReferenceltArraygt Iteratorscontained in the range are non-const
ReferenceltArraygtamp ref ReferenceltArraygt
matlabdataReferenceltArraygt
1-25
RangeltTypedIterator Tgt Range containing begin and end iterators for theelements of the input ReferenceltArraygt
InvalidArrayTypeException
Array does not contain type T
See AlsoArrayType
Introduced in R2017b
1 API Reference
1-26
matlabdataArrayTypeC++ array type enumeration class
DescriptionUse ArrayType objects to identify the data type and other attributes of a MATLABarray
Class DetailsNamespace matlabdataInclude ArrayTypehpp
Enumerationenum class ArrayType UNKNOWN LOGICAL CHAR DOUBLE SINGLE INT8 UINT8 INT16 UINT16 INT32 UINT32 INT64 UINT64 COMPLEX_DOUBLE COMPLEX_SINGLE COMPLEX_INT8 COMPLEX_UINT8 COMPLEX_INT16 COMPLEX_UINT16 COMPLEX_INT32 COMPLEX_UINT32
matlabdataArrayType
1-27
COMPLEX_INT64 COMPLEX_UINT64 CELL STRUCT OBJECT VALUE_OBJECT HANDLE_OBJECT_REF ENUM SPARSE_LOGICAL SPARSE_DOUBLE SPARSE_COMPLEX_DOUBLE MATLAB_STRING
C++ Data Type ConversionMATLAB ArrayType Value C++ Type DescriptionDOUBLE double double-precision (64-bit)
floating-point numberSINGLE float single-precision (32-bit)
floating-point numberINT8 int8_t signed 8-bit integerUINT8 uint8_t unsigned 8-bit integerINT16 int16_t signed 16-bit integerUINT16 uint16_t unsigned 16-bit integerINT32 int32_t signed 32-bit integerUINT32 uint32_t unsigned 32-bit integerINT64 int64_t signed 64-bit integerUINT64 uint64_t unsigned 64-bit integerCHAR char16_t 16-bit characterLOGICAL bool logicalCOMPLEX_DOUBLE stdcomplexltdoublegt complex double-precision
(64-bit) floating-pointnumber
1 API Reference
1-28
MATLAB ArrayType Value C++ Type DescriptionCOMPLEX_SINGLE stdcomplexltfloatgt complex single precision
(32-bit) floating-pointnumber
COMPLEX_INT8 stdcomplexltint8_tgt complex signed 8-bitinteger
COMPLEX_UINT8 stdcomplexltuint8_tgt complex unsigned 8-bitinteger
COMPLEX_INT16 stdcomplexltint16_tgt complex signed 16-bitinteger
COMPLEX_UINT16 stdcomplexltuint16_tgt complex unsigned 16-bitinteger
COMPLEX_INT32 stdcomplexltint32_tgt complex signed 32-bitinteger
COMPLEX_UINT32 stdcomplexltuint32_tgt complex unsigned 32-bitinteger
COMPLEX_INT64 stdcomplexltint64_tgt complex signed 64-bitinteger
COMPLEX_UINT64 stdcomplexltuint64_tgt complex unsigned 64-bitinteger
CELL matlabdataArray Array containing otherArrays
STRUCT matlabdataStruct Array with named fieldsthat can contain data ofvarying types and sizes
OBJECT matlabdataObject MATLAB objectVALUE_OBJECT matlabdataObject MATLAB value objectHANDLE_OBJECT_REF matlabdataObject Reference to an existing
handle object in MATLABENUM matlabdataEnumerat
ionArray of enumerationvalues
SPARSE_LOGICAL bool Sparse array of logicalSPARSE_DOUBLE double Sparse array of double
matlabdataArrayType
1-29
MATLAB ArrayType Value C++ Type DescriptionSPARSE_COMPLEX_DOUBLE stdcomplexltdoublegt Sparse array of complex
doubleMATLAB_STRING matlabdataMATLABSt
ringMATLAB string
See AlsoArrayVisitors
Introduced in R2017b
1 API Reference
1-30
matlabdataArrayVisitorsFunctions for defining visitor pattern
DetailsNamespace matlabdataInclude ArrayVisitorshpp
Functionsbull ldquoapply_visitorrdquo on page 1-31bull ldquoapply_visitor_refrdquo on page 1-31
apply_visitorauto apply_visitor(Array a V visitor)
TBD
TBD
InvalidArrayTypeException
apply_visitor_refauto apply_visitor_ref(const ArrayRefamp a V visitor)
Apply functor V to Array a
Result of V
matlabdataArrayVisitors
1-31
InvalidArrayTypeException
See Also
Introduced in R2017b
1 API Reference
1-32
matlabdataCellArrayC++ class to access MATLAB cell arrays
DescriptionA CellArray is a TypedArray with Array as the element type Use CellArray objectsto access MATLAB cell arrays To create a CellArray call createCellArrayCellArray is defined as
using CellArray = TypedArrayltArraygt
Class DetailsNamespace matlabdataInclude TypedArrayhpp
ExamplesCreate Cell Array
Create a cell array with two elements
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory CellArray cellArray1 = factorycreateCellArray( 12 factorycreateCharArray(MATLAB Cell Array) factorycreateArrayltdoublegt( 22 12 22 32 42 ))
matlabdataCellArray
1-33
return 0
See AlsocreateCellArray
Introduced in R2017b
1 API Reference
1-34
matlabdataCharArrayC++ class to access MATLAB character arrays
DescriptionUse CharArray objects to work with MATLAB character arrays To create a CharArraycall createCharArray
Class DetailsNamespace matlabdataBase class TypedArrayltchar16_tgtInclude CharArrayhpp
Constructorsbull ldquoCopy Constructorsrdquo on page 1-35bull ldquoCopy Assignment Operatorsrdquo on page 1-36bull ldquoMove Constructorsrdquo on page 1-37bull ldquoMove Assignment Operatorsrdquo on page 1-37
Copy Constructors
CharArray(const CharArrayamp rhs)
CharArray(const Arrayamp rhs)
Creates a shared data copy of a CharArray object
const CharArrayamp rhs Value to copyconst Arrayamp rhs Value specified as ArrayTypeCHAR object
matlabdataCharArray
1-35
InvalidArrayTypeException
Type of input Array is not ArrayTypeCHAR
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory CharArray A = factorycreateCharArray(This is a char array) CharArray B(A) return 0
createCharArray on page 1-16
Copy Assignment OperatorsCharArrayamp operator=(const CharArrayamp rhs)
CharArrayamp operator=(const Arrayamp rhs)
Assigns a shared data copy to a CharArray object
const CharArrayamp rhs Value to copyconst Arrayamp rhs Value specified as ArrayTypeCHAR object
CharArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not ArrayTypeCHAR
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory CharArray A = factorycreateCharArray(This is a char array) CharArray C = factorycreateCharArray()
1 API Reference
1-36
Arrays A and C refer to the same data C = A
return 0
Move Constructors
CharArray(CharArrayampamp rhs)
CharArray(Arrayampamp rhs)
Moves contents of a CharArray object to a new instance
CharArrayampamp rhs Value to moveArrayampamp rhs Value specified as ArrayTypeCHAR object
InvalidArrayTypeException
Type of input Array is not ArrayTypeCHAR
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory CharArray A = factorycreateCharArray(This is a char array)
Move constructor - Creates B copies data from A A not valid CharArray B(stdmove(A))
return 0
Move Assignment Operators
CharArrayamp operator=(CharArrayampamp rhs)
CharArrayamp operator=(Arrayampamp rhs)
matlabdataCharArray
1-37
Assigns the input to this CharArray object
CharArrayampamp rhs Value to moveArrayampamp rhs Value specified as ArrayTypeCHAR object
CharArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not ArrayTypeCHAR
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory CharArray A = factorycreateCharArray(This is a char array)
Move assignment - Data from A moved to C A no longer valid CharArray C = factorycreateCharArray() C = stdmove(A)
return 0
Member Functionsbull ldquotoUTF16rdquo on page 1-38bull ldquotoAsciirdquo on page 1-39
toUTF16String toUTF16() const
matlabdataString Contents of CharArray as matlabdataString
None
1 API Reference
1-38
toAsciistdstring toAscii() const
stdstring Contents of CharArray as ASCII string
NonAsciiCharInRequestedAsciiOutputException
Data contains non-ASCII characters
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory f auto arr = fcreateCharArray(helloworld) stdstring s = arrtoAscii()
return 0
ldquoEvaluate Mathematical Function in MATLABrdquo
See AlsoldquocreateCharArrayrdquo on page 1-16 | TypedArray | matlabdataString
Introduced in R2017b
matlabdataCharArray
1-39
matlabdataReferenceltCharArraygtC++ class to get reference to CharArray
DescriptionThe CharArrayExt class extends the APIs available to a reference to a CharArray
Class DetailsNamespace matlabdataBase class ReferenceltArraygtInclude TypedArrayRefhpp
Member Functionsbull ldquotoUTF16rdquo on page 1-40bull ldquotoAsciirdquo on page 1-40
toUTF16String toUTF16() const
matlabdataString Contents of reference to CharArray as a utf16 string
None
toAsciistdstring toAscii() const
stdstring Contents of reference to CharArray asmatlabdataString
1 API Reference
1-40
NonAsciiCharInRequestedAsciiOutputException
Data contains non-ASCII characters
See AlsoCharArray | ReferenceltTypedArrayltTgtgt
Introduced in R2017b
matlabdataReferenceltCharArraygt
1-41
matlabdataEnumArrayC++ class to access MATLAB enumeration arrays
DescriptionUse EnumArray objects to access enumeration arrays To create an EnumArray callcreateEnumArray
Class DetailsNamespace matlabdataBase class TypedArrayltEnumerationgtInclude EnumArrayhpp
Constructorsbull ldquoCopy Constructorsrdquo on page 1-42bull ldquoCopy Assignment Operatorsrdquo on page 1-43bull ldquoMove Constructorsrdquo on page 1-43bull ldquoMove Assignment Operatorsrdquo on page 1-43
Copy Constructors
EnumArray(const EnumArrayamp rhs)
EnumArray(const Arrayamp rhs)
Creates a shared data copy of an EnumArray object
const EnumArrayamp rhs Value to copyconst Arrayamp rhs Value specified as EnumArray object
1 API Reference
1-42
InvalidArrayTypeException
Type of input Array is not ArrayTypeENUM
Copy Assignment OperatorsEnumArrayamp operator=(const EnumArrayamp rhs)
EnumArrayamp operator=(const Arrayamp rhs)
Assigns a shared data copy to an EnumArray object
const EnumArrayamp rhs Value to copyconst Arrayamp rhs Value specified as ArrayTypeENUM object
EnumArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not ArrayTypeENUM
Move ConstructorsEnumArray(EnumArrayampamp rhs)
EnumArray(Arrayampamp rhs)
Moves contents of an EnumArray object to a new instance
EnumArrayampamp rhs Value to moveArrayampamp rhs Value specified as ArrayTypeENUM object
InvalidArrayTypeException
Type of input Array is not ArrayTypeENUM
Move Assignment OperatorsEnumArrayamp operator=(EnumArrayampamp rhs)
matlabdataEnumArray
1-43
EnumArrayamp operator=(Arrayampamp rhs)
Assigns the input to this EnumArray object
EnumArrayampamp rhs Value to moveArrayampamp rhs Value specified as ArrayTypeENUM object
EnumArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not ArrayTypeENUM
Member Functions
getClassNamestdstring getClassName() const
Return class name for this EnumArray
stdstring The class name
None
See AlsoldquocreateEnumArrayrdquo on page 1-18 | TypedArray
Introduced in R2017b
1 API Reference
1-44
matlabdataReferenceltEnumArraygtC++ class to get reference to EnumArray
DescriptionThe EnumArrayExt class extends the APIs available to a reference to an EnumArray
Class DetailsNamespace matlabdataBase class ReferenceltArraygtInclude TypedArrayRefhpp
Member Functions
getClassNamestdstring getClassName() const
Return class name for this reference to an EnumArray object
stdstring Class name
None
See AlsoEnumArray | ReferenceltTypedArrayltTgtgt
Introduced in R2017b
matlabdataReferenceltEnumArraygt
1-45
matlabdataEnumerationElement type for MATLAB enumeration arrays
DescriptionEnumeration is the element type for an EnumArray object
Class DetailsNamespace matlabdataInclude Enumerationhpp
See AlsoEnumArray
TopicsldquoMATLAB Data API Typesrdquo
Introduced in R2017b
1 API Reference
1-46
matlabExceptionC++ base class for exceptions
DescriptionAll MATLAB C++ exceptions can be caught as matlabException
Class DetailsNamespace matlabInclude Exceptionhpp
See Also
TopicsldquoMATLAB Data API Exceptionsrdquo
Introduced in R2017b
matlabException
1-47
matlabdataForwardIteratorltTgtTemplated C++ class to provide forward iterator support for StructArray field names
DescriptionUse ForwardIterator objects to access a range of field name elements in aStructArray
Class DetailsNamespace matlabdataInclude ForwardIteratorhpp
Template ParametersT matlabdataMATLABFieldIdentifier
Constructorsbull ldquoCopy Constructorsrdquo on page 1-48bull ldquoCopy Assignment Operatorsrdquo on page 1-49
Copy Constructors
ForwardIterator(const ForwardIteratorltTgtamp rhs)
Creates a shared data copy of a ForwardIteratorltTgt object
constForwardIteratorltTgtamp rhs
Object to copy
ForwardIterator New instance
1 API Reference
1-48
None
Copy Assignment Operators
ForwardIteratorltTgtamp operator=(const ForwardIteratorltTgtamp rhs)
Assigns a shared data copy to a ForwardIteratorltTgt object
constForwardIteratorltTgtamp rhs
Object to assign
ForwardIteratorltTgt Updated instance
None
Other Operatorsbull ldquooperator++rdquo on page 1-49bull ldquooperator--rdquo on page 1-50bull ldquooperator=rdquo on page 1-50bull ldquooperator=rdquo on page 1-50bull ldquooperatorrdquo on page 1-51bull ldquooperator-gtrdquo on page 1-51bull ldquooperator[]rdquo on page 1-51
operator++ForwardIteratorltTgtamp operator++()
Pre-increment operator
ForwardIteratorltTgtamp Reference to updated value
matlabdataForwardIteratorltTgt
1-49
None
operator--ForwardIteratorltTgt operator--(int)
Post-increment operator
ForwardIteratorltTgt New object
None
operator=bool operator==(const ForwardIteratorltTgtamp rhs) const
constForwardIteratorltTgtamp rhs
Iterator to compare
bool Returns true if the iterators point to the same elementOtherwise returns false
None
operator=bool operator=(const ForwardIteratorltTgtamp rhs) const
constForwardIteratorltTgtamp rhs
Iterator to compare
bool Returns true if this iterator points to a differentelement Otherwise returns false
None
1 API Reference
1-50
operatorreference operator() const
reference Shared copy of element that iterator points to specifiedas
bull Tamp for arithmetic typesbull ReferenceltTgt for non-arithmetic types
None
operator-gtpointer operator-gt()
pointer Pointer to element pointed to by this iterator specifiedas
bull T for arithmetic typesbull ReferenceltTgt for non-arithmetic types
None
operator[]reference operator[](const size_tamp rhs) const
Get a reference using a linear index
reference Element pointed to by this iterator specified as
bull Tamp for arithmetic typesbull ReferenceltTgt for non-arithmetic types
None
matlabdataForwardIteratorltTgt
1-51
See AlsoMATLABFieldIdentifier | StructArray
Introduced in R2017b
1 API Reference
1-52
matlabdataGetArrayTypeC++ struct TBD
DescriptionUse GetArrayType objects to TBD
Class DetailsNamespace matlabdataInclude GetArrayTypehpp
See Also
Introduced in R2017b
matlabdataGetArrayType
1-53
matlabdataGetReturnTypeC++ struct TBD
DescriptionUse GetReturnType to convert a template argument to the appropriate templateargument when creating a TypedArray
Class DetailsNamespace matlabdataInclude GetReturnTypehpp
See Also
Introduced in R2017b
1 API Reference
1-54
matlabdataMATLABFieldIdentifierC++ class used to identify field names in MATLAB struct array
Description
Class DetailsNamespace matlabdataInclude MATLABFieldIdentifierhpp
Constructorsbull ldquoDefault Constructorrdquo on page 1-55bull ldquoConstructorrdquo on page 1-55bull ldquoDestructorrdquo on page 1-56bull ldquoCopy Constructorsrdquo on page 1-56bull ldquoCopy Assignment Operatorsrdquo on page 1-56bull ldquoMove Constructorsrdquo on page 1-57bull ldquoMove Assignment Operatorsrdquo on page 1-57
Default ConstructorMATLABFieldIdentifier()
Construct an empty MATLABFieldIdentifier
None
ConstructorMATLABFieldIdentifier(stdstring str)
matlabdataMATLABFieldIdentifier
1-55
Construct a MATLABFieldIdentifier from stdstring
stdstring str String that contains the field name
Destructor
~MATLABFieldIdentifier()
Destroy a MATLABFieldIdentifier
None
Copy Constructors
MATLABFieldIdentifier(const MATLABFieldIdentifieramp rhs)
Creates a shared data copy of a MATLABFieldIdentifier object
constMATLABFieldIdentifieramprhs
Value to copy
None
Copy Assignment Operators
MATLABFieldIdentifieramp operator=(MATLABFieldIdentifier constamp rhs)
Assigns a shared data copy to a MATLABFieldIdentifier object
MATLABFieldIdentifierconstamp rhs
Value to move
1 API Reference
1-56
MATLABFieldIdentifieramp Updated instance
None
Move Constructors
MATLABFieldIdentifier(MATLABFieldIdentifierampamp rhs)
Moves contents a MATLABFieldIdentifier object to a new instance
MATLABFieldIdentifierampamprhs
Value to move
None
Move Assignment Operators
MATLABFieldIdentifieramp operator=(MATLABFieldIdentifierampamp rhs)
MATLABFieldIdentifierampamprhs
Value to move
MATLABFieldIdentifieramp Updated instance
None
Destructor~MATLABFieldIdentifier()
Description
Destroy a MATLABFieldIdentifier
matlabdataMATLABFieldIdentifier
1-57
Other Operators
operator stdstringoperator stdstring() const
stdstring Representation of the MATLABFieldIdentifier object
None
Free Functions
operator==bool operator==(const MATLABFieldIdentifieramp rhs) const
Check if two MATLABFieldIdentifier objects are identical
constMATLABFieldIdentifieramprhs
Value to be compared
bool Returns true if the objects are identical Otherwisereturns false
None
See AlsoForwardIterator | StructArray
Introduced in R2017b
1 API Reference
1-58
matlabdataMATLABStringElement type for MATLAB string arrays
DescriptionMATLABString is defined as
using MATLABString = OptionalltStringgt
Class DetailsNamespace matlabdataInclude Stringhpp
See AlsomatlabdataString
Introduced in R2017b
matlabdataMATLABString
1-59
matlabdataReferenceltMATLABStringgtC++ class to get reference to element of StringArray
DescriptionA ReferenceltMATLABStringgt object is created when using operator[] into anStringArray or dereferenceing a String arrary iterator
Class DetailsNamespace matlabdataInclude MATLABStringReferenceExthpp
Cast
String()operator String() const
matlabdataString Element of a MATLABString array converted toString
NotEnoughIndicesProvidedException
Not enough indices provided
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
TooManyIndicesProvidedException
Too many indices provided
stdruntime_error Array element does not have a value
1 API Reference
1-60
Member Functionsbull ldquoboolrdquo on page 1-61bull ldquohas_valuerdquo on page 1-61
booloperator bool() const
Check whether string contains a value
operator True if string contains a value
NotEnoughIndicesProvidedException
Not enough indices provided
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
TooManyIndicesProvidedException
Too many indices provided
has_valuebool has_value() const
Check whether string contains a value
bool True if string contains a value
NotEnoughIndicesProvidedException
Not enough indices provided
InvalidArrayIndexException
Index provided is not valid for this Array or one of theindices is out of range
TooManyIndicesProvidedException
Too many indices provided
matlabdataReferenceltMATLABStringgt
1-61
See Also
Introduced in R2017b
1 API Reference
1-62
matlabdataArrayC++ base class for all array types
DescriptionUse Array objects to represent single and multi-dimensional arrays The Array classprovides methods for users to be able to query generic information about all arrays suchas dimensions and type and has methods to create deep copies and shared data copiesUse ArrayFactory methods to construct Arrays Once an Array has been constructedit can be moved or cloned (deep-copied) or a shared-data copy can be created Arrayssupport copy-on-write semantics
Class DetailsNamespace matlabdataInclude MDArrayhpp
Constructorsbull ldquoDefault Constructorrdquo on page 1-63bull ldquoCopy Constructorsrdquo on page 1-64bull ldquoCopy Assignment Operatorsrdquo on page 1-64bull ldquoMove Constructorsrdquo on page 1-64bull ldquoMove Assignment Operatorsrdquo on page 1-65
Default Constructor
Array()
None
matlabdataArray
1-63
Copy Constructors
Array(const Arrayamp rhs)
Creates a shared data copy of an Array object
const Arrayamp rhs Value to copy
None
Copy Assignment Operators
Arrayamp operator=(const Arrayamp rhs)
Assigns a shared data copy to an Array object
const Arrayamp rhsrhs Value to copy
Arrayamp Updated instance
None
Move Constructors
Array(Arrayampamp rhs)
Moves contents of an Array object to a new instance
Arrayampamp rhs Value to move
None
1 API Reference
1-64
Move Assignment Operators
Arrayamp operator=(Arrayampamp rhs)
Assigns the input to this Array object
Arrayampamp rhs Value to move
Arrayamp Updated instance
None
Destructorvirtual ~Array()
Indexing Operators
operator[]ArrayElementRefltfalsegt operator[](size_t idx)
ArrayElementReflttruegt operator[](size_t idx) const
Enables [] indexing on const and non-const arrays Indexing is 0-based
size_t idx First array index
ArrayElementRefltfalsegt Temporary object containing the index specified Thereturn value allows the element of the array to bemodified or retrieved
matlabdataArray
1-65
ArrayElementReflttruegt Temporary object containing the index specified Thereturn value allows the element of the array to beretrieved but not modified
None
Member Functionsbull ldquogetTyperdquo on page 1-66bull ldquogetDimensionsrdquo on page 1-66bull ldquogetNumberOfElementsrdquo on page 1-66bull ldquoisEmptyrdquo on page 1-67
getTypeArrayType getType() const
ArrayType Array type
None
getDimensionsArrayDimensions getDimensions() const
ArrayDimensions Vector of each dimension in the array
None
getNumberOfElementssize_t getNumberOfElements() const
size_t The number of elements in the array
1 API Reference
1-66
None
isEmptybool isEmpty() const
bool True if array is empty False if array is not empty
None
Free Functionsbull ldquogetReadOnlyElementsrdquo on page 1-67bull ldquogetWritableElementsrdquo on page 1-67
getReadOnlyElementstemplate lttypename TgtRangeltTypedIterator T constgt getReadOnlyElements(const Arrayamp arr)
Get a range containing the elements of the Array Iterators contained in the range areconst
const Arrayamp arr Array
RangeltTypedIterator Tconstgt
Range containing begin and end iterators for the inputArray
InvalidArrayTypeException
Array does not contain type T
getWritableElementstemplate lttypename TgtRangeltTypedIterator Tgt getWritableElements(Arrayamp arr)
matlabdataArray
1-67
Get a range containing the elements of the Array Iterators contained in the range arenon-const
Arrayamp arr Array
RangeltTypedIterator Tgt Range containing begin and end iterators for the inputArray
InvalidArrayTypeException
Array does not contain type T
See AlsoArrayFactory
Introduced in R2017b
1 API Reference
1-68
matlabdataObjectElement type for MATLAB object arrays
DescriptionObject is the element type for an ObjectArray
Class DetailsNamespace matlabdataInclude Objecthpp
See AlsoObjectArray
Introduced in R2017b
matlabdataObject
1-69
matlabdataObjectArrayC++ class to access MATLAB object arrays
DescriptionUse ObjectArray objects to access MATLAB object arrays You do not create anObjectArray only MATLAB functions create ObjectArrays You can pass anObjectArray to a MATLAB function
ObjectArray is defined as
using ObjectArray = TypedArrayltObjectgt
Class DetailsNamespace matlabdataInclude ObjectArrayhpp
See AlsoObject
Introduced in R2017b
1 API Reference
1-70
matlabdataOptionalltTgtTemplated C++ class representing optional values
DescriptionUse Optional objects to represent values that might or might not exist
Class DetailsNamespace matlabdataInclude Optionalhpp
Template ParametersT Array type specified as matlabdataString
Constructorsbull ldquoDefault Constructorsrdquo on page 1-71bull ldquoCopy Constructorsrdquo on page 1-71bull ldquoCopy Assignment Operatorsrdquo on page 1-72bull ldquoMove Constructorsrdquo on page 1-72bull ldquoMove Assignment Operatorsrdquo on page 1-72
Default Constructors
optional()
Copy Constructors
optional(const optionalamp other)
matlabdataOptionalltTgt
1-71
Creates a shared data copy
const optionalamp other Value to copy
None
Copy Assignment OperatorsoptionalltTgtamp operator=(const optionalltTgtamp other)
Assigns a shared data copy
const optionalltTgtamp other Value to copy
optionalltTgtamp Updated instance
None
Move Constructorsoptional(optionalampamp other)
optional(Tampamp value)
Moves contents of an Optional object to a new instance
optionalampamp other Value to moveTampamp value Value of type T to move
None
Move Assignment OperatorsoptionalltTgtamp operator=(optionalltTgtampamp other)
1 API Reference
1-72
optionalltTgtamp operator=(Tampamp value)
Assigns the input to this instance
optionalltTgtampamp other
Tampamp value
Value to move
optionalltTgtamp Updated instance
None
Other Operatorsbull ldquooperator=rdquo on page 1-73bull ldquooperator-gtrdquo on page 1-74bull ldquooperatorrdquo on page 1-74bull ldquooperator Trdquo on page 1-74
operator=optionalltTgtamp operator=(nullopt_t)
optionalltTgtamp operator=(const optionalltTgtamp other)
optionalltTgtamp operator=(optionalltTgtampamp other)
optionalltTgtamp operator=(Tampamp value)
optionalltTgtamp operator=(const Tamp value)
Assignment operators
optionalltTgtamp Updated instance
None
matlabdataOptionalltTgt
1-73
operator-gtconst T operator-gt() const
T operator-gt()
const T
T
Pointer to the element
stdruntime_error Optional object does not contain a value
operatorconst Tamp operator() const
Tamp operator()
const Tamp
Tamp
Reference to the element
stdruntime_error Optional object does not contain a value
operator Toperator T() const
Cast optionalltTgt value to T
operator Value contained in optionalltTgt if it exists
stdruntime_error There is no value
1 API Reference
1-74
Member Functionsbull ldquoboolrdquo on page 1-75bull ldquohas_valuerdquo on page 1-75bull ldquoswaprdquo on page 1-75bull ldquoresetrdquo on page 1-76
boolexplicit operator bool() const
Check whether object contains a value
operator True if object contains a value
None
has_valuebool has_value() const
Check whether object contains a value
bool True if object contains a value
None
swapvoid swap(optional ampother)
Swap value of this optional instance with value contained in the parameter
optional ampother Value to swap
matlabdataOptionalltTgt
1-75
None
resetvoid reset()
Reset optional value to missing
None
See Also
Introduced in R2017b
1 API Reference
1-76
matlabdataRangeltItTypeElemTypegtTemplated C++ class to provide range-based operation support
DescriptionRange objects wrap begin and end functions to enable range-based operations
Class DetailsNamespace matlabdataInclude Rangehpp
Template ParametersIteratorType Iterator typeElementType Element type
Constructorsbull ldquoConstructorrdquo on page 1-77bull ldquoMove Constructorsrdquo on page 1-78bull ldquoMove Assignment Operatorsrdquo on page 1-78
Constructor
Range(IteratorTypeltElementTypegt begin IteratorTypeltElementTypegtend)
Creates a Range object
matlabdataRangeltItTypeElemTypegt
1-77
IteratorTypeltElementTypegt begin
IteratorTypeltElementTypegt end
First and last elements of range
Range New instance
None
Move Constructors
Range(Rangeampamp rhs)
Moves contents of a Range object to a new instance
Rangeampamp rhs Range to move
Range New instance
None
Move Assignment Operators
Rangeamp operator=(Rangeampamp rhs)
Assigns the input to this Range object
Rangeampamp rhs Range to move
Rangeamp Updated instance
None
1 API Reference
1-78
beginIteratorTypeltElementTypegtamp begin()
ReturnsIteratorTypeltElementTypegtamp
First element in range
None
endIteratorTypeltElementTypegtamp end()
ReturnsIteratorTypeltElementTypegtamp
End of range
None
See Also
Introduced in R2017b
matlabdataRangeltItTypeElemTypegt
1-79
matlabdataReferenceltTgtTemplated C++ class to get references to Array elements
DescriptionA Reference object is a reference to an element of an Array without making a copy AReference is
bull Not a shared copybull Valid as long as the array that contains the reference is validbull Not thread-safe
Class DetailsNamespace matlabdataInclude Referencehpp
Template ParametersT Type of element referred to specified as
bull Arraybull Structbull Enumerationbull MATLABStringbull All stdcomplex types
Constructorsbull ldquoCopy Constructorrdquo on page 1-81bull ldquoCopy Assignment Operatorsrdquo on page 1-81bull ldquoMove Assignment Operatorsrdquo on page 1-81
1 API Reference
1-80
bull ldquoMove Constructorsrdquo on page 1-81
Copy ConstructorReference(const ReferenceltTgtamp rhs)
const ReferenceltTgtamp rhs Value to copy
Copy Assignment OperatorsReferenceltTgtamp operator=(const ReferenceltTgtamp rhs)
const ReferenceltTgtamp rhs Value to copy
ReferenceltTgtamp Updated instance
Move Assignment OperatorsReferenceltTgtamp operator=(ReferenceltTgtampamp rhs)
ReferenceltTgtampamp rhs Value to move
ReferenceltTgtamp Updated instance
None
Move ConstructorsReference(ReferenceltTgtampamp rhs)
Moves contents of a Reference object to a new instance
ReferenceltTgtampamp rhs Value to move
None
matlabdataReferenceltTgt
1-81
Other Operatorsbull ldquooperator=rdquo on page 1-82bull ldquooperatorltltrdquo on page 1-82bull ldquooperator T()rdquo on page 1-83bull ldquooperator stdstring()rdquo on page 1-83
operator=ReferenceltTgtamp operator=(T rhs)
ReferenceltTgtamp operator=(stdstring rhs)
ReferenceltTgtamp operator=(String rhs)
T rhs Value to assign The array being indexed must be non-const
stdstring rhs String to assign The array must be non-const andallow strings to be assigned
String rhs String to assign to StringArray The array beingindexed must be non-const
ReferenceltTgtamp Updated instance
None
operatorltlt
stdostreamamp operator ltlt(stdostreamamp os ReferenceltTgt constamp rhs)
stdostreamamp os ReferenceltTgt constamp rhs
stdostreamamp
1 API Reference
1-82
operator T()operator T() const
Cast to element from the array
T Shared copy of element from the array
None
operator stdstring()operator stdstring() const
Cast to stdstring from the array Makes a copy of the stdstring Only valid fortypes that can be cast to a stdstring
stdstring The string
NonAsciiCharInInputDataException
Input is stdstring and contains non-ASCIIcharacters
stdruntime_error MATLABString is missing
Free Functions
operator==inline bool operator ==(ReferenceltMATLABStringgt constamp lhsstdstring constamp rhs)
inline bool operator ==(stdstring constamp lhsReferenceltMATLABStringgt constamp rhs)
inline bool operator ==(ReferenceltMATLABStringgt constamp lhs Stringconstamp rhs)
matlabdataReferenceltTgt
1-83
inline bool operator ==(String constamp lhs ReferenceltMATLABStringgtconstamp rhs)
inline bool operator ==(ReferenceltMATLABStringgt constamp lhsMATLABString constamp rhs)
inline bool operator ==(MATLABString constamp lhsReferenceltMATLABStringgt constamp rhs)
inline bool operator ==(ReferenceltMATLABStringgt constamp lhsReferenceltMATLABStringgt constamp rhs)
templatelttypename Tgt bool operator ==(ReferenceltTgt constamp lhs Tconstamp rhs)
templatelttypename Tgt bool operator ==(T constamp lhs ReferenceltTgtconstamp rhs)
templatelttypename Tgt bool operator ==(ReferenceltTgt constamp lhsReferenceltTgt constamp rhs)
ReferenceltMATLABStringgtconstamp lhs
stdstring constamp rhs Values tocompare
stdstring constamp lhs ReferenceltMATLABStringgtconstamp rhs
ReferenceltMATLABStringgtconstamp lhs
String constamp rhs
String constamp lhs ReferenceltMATLABStringgtconstamp rhs
ReferenceltMATLABStringgtconstamp lhs
MATLABString constamp rhs
MATLABString constamp lhs ReferenceltMATLABStringgtconstamp rhs
ReferenceltMATLABStringgtconstamp lhs
ReferenceltMATLABStringgtconstamp rhs
ReferenceltTgt constamp lhs T constamp rhsT constamp lhs ReferenceltTgt constamp rhsReferenceltTgt constamp lhs ReferenceltTgt constamp rhs
1 API Reference
1-84
bool Returns true if values are equal
stdruntime_error Cannot compare argument to MATLABString
See Also
TopicsldquoAccess C++ Data Array Container Elementsrdquo
Introduced in R2017b
matlabdataReferenceltTgt
1-85
matlabdataSparseArrayltTgtTemplated C++ class to access data in MATLAB sparse arrays
DescriptionUse SparseArray objects to work with sparse MATLAB arrays To create aSparseArray call createSparseArray
Class DetailsNamespace matlabdataBase class matlabdataArrayInclude SparseArrayhpp
Template ParametersT Type of element referred to specified as
bull boolbull doublebull stdcomplexltdoublegt
Constructorsbull ldquoCopy Constructorsrdquo on page 1-86bull ldquoCopy Assignment Operatorsrdquo on page 1-87bull ldquoMove Constructorsrdquo on page 1-87bull ldquoMove Assignment Operatorsrdquo on page 1-88
Copy Constructors
SparseArray(const SparseArrayltTgtamp rhs)
1 API Reference
1-86
SparseArray(const Arrayamp rhs)
Creates a shared data copy of a SparseArray object
const SparseArrayltTgtamprhs
Value to copy
const Arrayamp rhs Value specified as an Array ofArrayTypeSPARSE_LOGICALArrayTypeSPARSE_DOUBLE orArrayTypeSPARSE_COMPLEX_DOUBLE
InvalidArrayTypeException
Type of input Array is not sparse
Copy Assignment OperatorsSparseArrayamp operator=(const SparseArrayltTgtamp rhs)
SparseArrayamp operator=(const Arrayamp rhs)
Assigns a shared data copy to a SparseArray object
const SparseArrayltTgtamprhs
Value to copy
const Arrayamp rhs Value specified as an Array of typeArrayTypeSPARSE_LOGICALArrayTypeSPARSE_DOUBLE orArrayTypeSPARSE_COMPLEX_DOUBLE
SparseArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not sparse
Move ConstructorsSparseArray(SparseArrayampamp rhs)
matlabdataSparseArrayltTgt
1-87
SparseArray(Arrayampamp rhs)
Moves contents a SparseArray object to a new instance
const SparseArrayltTgtamprhs
Value to move
const Arrayamp rhs Value specified as an Array of typeArrayTypeSPARSE_LOGICALArrayTypeSPARSE_DOUBLE orArrayTypeSPARSE_COMPLEX_DOUBLE
InvalidArrayTypeException
Type of input Array is not sparse
Move Assignment Operators
SparseArrayamp operator=(SparseArrayltTgtampamp rhs)
SparseArrayamp operator=(Arrayampamp rhs)
Assigns the input to this SparseArray object
const SparseArrayltTgtamprhs
Value to move
const Arrayamp rhs Value specified as an Array of typeArrayTypeSPARSE_LOGICALArrayTypeSPARSE_DOUBLE orArrayTypeSPARSE_COMPLEX_DOUBLE
SparseArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not sparse
1 API Reference
1-88
Iteratorsbull ldquoBegin Iteratorsrdquo on page 1-89bull ldquoEnd Iteratorsrdquo on page 1-89
Begin Iterators
iterator begin()
const_iterator begin() const
const_iterator cbegin() const
ldquoiteratorrdquo
ldquoconst_iteratorrdquo
Iterator to beginning of array
None
End Iterators
iterator end()
const_iterator end() const
const_iterator cend() const
ldquoiteratorrdquo
ldquoconst_iteratorrdquo
Iterator to end of array
None
Member Functionsbull ldquogetNumberOfNonZeroElementsrdquo on page 1-90
matlabdataSparseArrayltTgt
1-89
bull ldquogetIndexrdquo on page 1-90
getNumberOfNonZeroElementssize_t getNumberOfNonZeroElements() const
Returns the number of nonzero elements in the array
size_t Number of nonzero elements in the array
None
getIndexSparseIndex getIndex(const TypedIteratorltTgtamp it)
SparseIndex getIndex(const TypedIteratorltT constgtamp it)
Returns the row-column coordinates of the nonzero entry that the iterator is pointing to
const TypedIteratorltTgtampit
Iterator pointing to the current entry in the sparsematrix
const TypedIteratorltTconstgtamp it
SparseIndex Row-column coordinates of the nonzero entry that theiterator is pointing to SparseIndex is defined asstdpairltsize_t size_tgt
None
See AlsoArray | createSparseArray
1 API Reference
1-90
Introduced in R2017b
matlabdataSparseArrayltTgt
1-91
matlabdataReferenceltSparseArrayltTgtgtTemplated C++ class to get reference to SparseArray
DescriptionUse the ReferenceltSparseArraygt class to get a reference to a SparseArray elementof a container object such as a MATLAB structure or cell array
Class DetailsNamespace matlabdataInclude SparseArrayRefhpp
Template ParametersT Type of elements in SparseArray specified as bool
double or stdcomplexltdoublegt
Iteratorsbull ldquoBegin Interatorsrdquo on page 1-92bull ldquoEnd Interatorsrdquo on page 1-93
Begin Interatorsiterator begin()
const_iterator begin() const
const_iterator cbegin() const
ldquoiteratorrdquo
ldquoconst_iteratorrdquo
Iterator to beginning of array Iterates over non-zeroelements of the SparseArray
1 API Reference
1-92
None
End Interators
iterator end()
const_iterator end() const
const_iterator cend() const
ldquoiteratorrdquo
ldquoconst_iteratorrdquo
Iterator to end of array
None
Member Functions
getNumberOfNonZeroElementssize_t getNumberOfNonZeroElements() const
Returns the number of nonzero elements in the array Since sparse arrays only storenonzero elements this method returns the actual array size It is different from arraydimensions that specify the full array size
size_t Number of nonzero elements in the array
None
See Also
Introduced in R2017b
matlabdataReferenceltSparseArrayltTgtgt
1-93
matlabdataStringType representing strings as stdbasic_stringltchar16_tgt
DescriptionThe String class defines the element type of a StringArray String is defined as
using String = stdbasic_stringltchar16_tgt
Class DetailsNamespace matlabdataInclude Stringhpp
See AlsomatlabdataMATLABString
Introduced in R2017b
1 API Reference
1-94
matlabdataStringArrayC++ class to access MATLAB string arrays
DescriptionUse StringArray objects to access MATLAB string arrays StringArray is defined as
using StringArray = TypedArrayltMATLABStringgt
Class DetailsNamespace matlabdataInclude TypedArrayhpp
See AlsomatlabdataMATLABString
Introduced in R2017b
matlabdataStringArray
1-95
matlabdataStructArrayC++ class to access MATLAB struct arrays
DescriptionUse StructArray objects to work with MATLAB struct arrays To access a field for asingle element in the array use the field name To create a StructArray object callcreateStructArray
Class DetailsNamespace matlabdataBase class TypedArrayltStructgtInclude StructArrayhpp
Constructorsbull ldquoCopy Constructorsrdquo on page 1-96bull ldquoCopy Assignment Operatorsrdquo on page 1-97bull ldquoMove Constructorsrdquo on page 1-97bull ldquoMove Assignment Operatorsrdquo on page 1-98
Copy Constructors
StructArray(const StructArrayamp rhs)
StructArray(const Arrayamp rhs)
Creates a shared data copy of a StructArray object
const StructArrayamp rhs Value to copy
1 API Reference
1-96
const Arrayamp rhs Value specified as ArrayTypeSTRUCT object
InvalidArrayTypeException
Type of input Array is not ArrayTypeSTRUCT
Copy Assignment Operators
StructArrayamp operator=(const StructArrayamp rhs)
StructArrayamp operator=(const Arrayamp rhs)
Assigns a shared data copy to a StructArray object
const StructArrayamp rhs Value to copyconst Arrayamp rhs Value specified as ArrayTypeSTRUCT object
StructArrayamp Updated instance
InvalidArrayTypeException
Type of input Array is not ArrayTypeSTRUCT
Move Constructors
StructArray(StructArrayampamp rhs)
StructArray(Arrayampamp rhs)
Moves contents of a StructArray object to a new instance
StructArrayampamp rhs Value to moveArrayampamp rhs Value specified as ArrayTypeSTRUCT object
InvalidArrayTypeException
Type of input Array is not ArrayTypeSTRUCT
matlabdataStructArray
1-97
Move Assignment OperatorsStructArrayamp operator=(StructArrayampamp rhs)
Assigns the input to this StructArray object
StructArrayampamp rhs Value to move
StructArrayamp Updated instance
None
Destructor~StructArray()
Description
Free memory for StructArray object
Member Functionsbull ldquogetFieldNamesrdquo on page 1-98bull ldquogetNumberOfFieldsrdquo on page 1-99
getFieldNamesRangeltForwardIterator MatlabFieldIdentifier constgt getFieldNames() const
RangeltForwardIteratorMatlabFieldIdentifierconstgt
Contains begin and end which enable access to allfields in StructArray object
None
1 API Reference
1-98
getNumberOfFieldssize_t getNumberOfFields() const
size_t Number of fields
None
ExamplesCreate StructArray
Suppose that you have the following MATLAB structure
s = struct(loc east west data [1 2 3] [4 5 6 7 8])
Create a variable containing the data for loc east
val = s(1)data
The following C++ code creates these variables
include MatlabDataArrayhpp
int main() using namespace matlabdata ArrayFactory factory
StructArray S = factorycreateStructArray( 12 loc data ) S[0][loc] = factorycreateCharArray(east) S[0][data] = factorycreateArrayltuint8_tgt( 1 3 1 2 3 ) S[1][loc] = factorycreateCharArray(west) S[1][data] = factorycreateArrayltdoublegt( 1 5 4 5 6 7 8 )
ReferenceltArraygt val = S[0][data] return 0
bull ldquoCreate Structure Array and Send to MATLABrdquo
matlabdataStructArray
1-99
See AlsoMATLABFieldIdentifier | Range | createStructArray
TopicsldquoCreate Structure Array and Send to MATLABrdquo
Introduced in R2017b
1 API Reference
1-100
matlabdataReferenceltStructArraygtC++ class to get reference to StructArray
DescriptionThe StructArrayExt class extends the APIs available to a reference to a StructArray
Class DetailsNamespace matlabdataBase class ReferenceltArraygtInclude TypedArrayRefhpp
Member Functionsbull ldquogetFieldNamesrdquo on page 1-101bull ldquogetNumberOfFieldsrdquo on page 1-101
getFieldNamesRangeltForwardIterator MATLABFieldIdentifier constgt getFieldNames() const
RangeltForwardIteratorMatlabFieldIdentifierconstgt
Contains begin and end which enables access to allfields in StructArray object
None
getNumberOfFieldssize_t getNumberOfFields() const
matlabdataReferenceltStructArraygt
1-101
size_t Number of fields
None
See AlsoReferenceltTypedArrayltTgtgt | StructArray
Introduced in R2017b
1 API Reference
1-102
matlabdataStructElement type for MATLAB struct arrays
DescriptionStruct is the element type for a StructArray object
Class DetailsNamespace matlabdataInclude Structhpp
Iteratorsbull ldquoBegin Iteratorsrdquo on page 1-103bull ldquoEnd Iteratorsrdquo on page 1-103
Begin Iteratorsconst_iterator begin() const
const_iterator cbegin() const
const_iterator Iterator to beginning of list of fields specified asTypedIteratorltArray constgt
None
End Iteratorsconst_iterator end() const
const_iterator cend() const
matlabdataStruct
1-103
const_iterator Iterator to end of list of fields specified asTypedIteratorltArray constgt
None
Indexing Operators
operator[]Array operator[](stdstring idx) const
Enables [] indexing on a StructArray object Indexing is 0-based
stdstring idx Field name
Array Shared copy of Array found at specified field
InvalidFieldNameException
Field does not exist in this StructArray
See AlsoldquocreateStructArrayrdquo on page 1-17 | StructArray
Introduced in R2017b
1 API Reference
1-104
matlabdataReferenceltStructgtC++ class to get reference to element of StructArray
DescriptionUse the ReferenceltStructgt class to access an element of a StructArray
Class DetailsNamespace matlabdataInclude StructRefhpp
Indexing Operators
operator[]ReferenceltArraygt operator[](stdstring idx)
Array operator[](stdstring idx) const
Index into the Struct with a field name
stdstring idx Field name
ReferenceltArraygt Reference to Array found at specified fieldArray Shared copy of Array found at specified field
InvalidFieldNameException
Field does not exist in the struct
matlabdataReferenceltStructgt
1-105
Iteratorsbull ldquoBegin Iteratorsrdquo on page 1-106bull ldquoEnd Iteratorsrdquo on page 1-106
Begin Iterators
iterator begin()
const_iterator begin() const
const_iterator cbegin() const
iterator Iterator to beginning of list of fields specified asTypedIteratorltTgt
const_iterator Iterator specified as TypedIteratorlttypenamestdadd_constltTgttypegt
None
End Iterators
iterator end()
const_iterator end() const
const_iterator cend() const
iterator Iterator to end of list of fields specified asTypedIteratorltTgt
const_iterator Iterator specified as TypedIteratorlttypenamestdadd_constltTgttypegt
None
1 API Reference
1-106
Cast
Struct()operator Struct() const
Create a shared copy of the Struct
Struct Shared copy
None
See Also
Introduced in R2017b
matlabdataReferenceltStructgt
1-107
matlabdataTypedArrayltTgtTemplated C++ class to access array data
DescriptionThe templated TypedArray class provides typesafe APIs to handle all array types(except sparse arrays) inside an array This class defines the following iterator types
using iterator = TypedIteratorltTgt
using const_iterator = TypedIteratorltT constgt
Class DetailsNamespace matlabdataBase class matlabdataArrayInclude TypedArrayhpp
Template ParametersT Type of element referred to
Template Instantiationsdoublefloatint8_tuint8_tint16_tuint16_tint32_tuint32_tint64_t
1 API Reference
1-108
uint64_tchar16_tboolstdcomplexltdoublegtstdcomplexltfloatgtstdcomplexltint8_tgtstdcomplexltuint8_tgtstdcomplexltint16_tgtstdcomplexltuint16_tgtstdcomplexltint32_tgtstdcomplexltuint32_tgtstdcomplexltint64_tgtstdcomplexltuint64_tgtmatlabdataArraymatlabdataStructmatlabdataEnumerationmatlabdataMATLABString
Constructorsbull ldquoCopy Constructorrdquo on page 1-109bull ldquoCopy Assignment Operatorrdquo on page 1-110bull ldquoMove Constructorrdquo on page 1-110bull ldquoMove Assignment Operatorrdquo on page 1-111
Copy ConstructorTypedArray(const TypedArrayltTgtamp rhs)
TypedArray(const Arrayamp rhs)
Creates a shared data copy of the input
matlabdataTypedArrayltTgt
1-109
const TypedArrayltTgtamp rhs Value to be copiedconst Arrayamp rhs Value specified as matlabdataArray object
InvalidArrayTypeException
Type of input Array does not match the type forTypedArrayltTgt
Copy Assignment Operator
TypedArrayltTgtamp operator=(const TypedArrayltTgtamp rhs)
TypedArrayltTgtamp operator=(const Arrayamp rhs)
Assigns a shared data copy of the input to this TypedArrayltTgt
const TypedArrayltTgtamp rhs Value to be copiedconst Arrayamp rhs Value specified as matlabdataArray object
TypedArrayltTgtamp Updated instance
InvalidArrayTypeException
Type of input Array does not match the type forTypedArrayltTgt
Move Constructor
TypedArray(TypedArrayltTgtampamp rhs)
TypedArray(Arrayampamp rhs)
Moves contents of the input to a new instance
TypedArrayltTgtampamp rhs Value to be movedArrayampamp rhs Value specified as matlabdataArray object
InvalidArrayTypeException
Type of input does not match
1 API Reference
1-110
Move Assignment Operator
TypedArrayltTgtamp operator=(TypedArrayltTgtampamp rhs)
TypedArrayltTgtamp operator=(Arrayampamp rhs)
Moves the input to this TypedArrayltTgt object
TypedArrayltTgtampamp rhs Value to move
TypedArrayltTgtamp Updated instance
InvalidArrayTypeException
Type of input Array does not match the type forTypedArrayltTgt
Destructorvirtual ~TypedArray()
Iteratorsbull ldquoBegin Iteratorsrdquo on page 1-111bull ldquoEnd Iteratorsrdquo on page 1-112
Begin Iterators
iterator begin()
const_iterator begin() const
const_iterator cbegin() const
iterator Iterator to beginning of array specified asTypedIteratorltTgt
matlabdataTypedArrayltTgt
1-111
const_iterator Iterator specified as TypedIteratorlttypenamestdadd_constltTgttypegt
None
End Iterators
iterator end()
const_iterator end() const
const_iterator cend() const
iterator Iterator to end of array specified asTypedIteratorltTgt
const_iterator Iterator specified as TypedIteratorlttypenamestdadd_constltTgttypegt
None
Indexing Operators
operator[]ArrayElementTypedRefltT stdis_constltTgtvaluegt operator[](size_tidx)
ArrayElementTypedRefltT truegt operator[](size_t idx) const
Enables [] indexing on a TypedArray Indexing is 0-based
size_t idx First array index
1 API Reference
1-112
ArrayElementTypedRefltTstdis_constltTgtvaluegt
Temporary object containing the index specified If typeT is const then the return value allows the element ofthe array to be retrieved but not modified Otherwisethe element can be modified or retrieved
ArrayElementTypedRefltTtruegt
Temporary object containing the index specified Thereturn value allows the element of the array to beretrieved but not modified
None
Suppose that you have a cell array c Assign a value to a ReferenceltArraygt object andcall the member function getType
ReferenceltArraygt r = c[0][0]auto t = c[0][0]getType
Member Functions
releasebuffer_ptr_tltTgt release()
Release the underlying buffer from the Array If the Array is shared a copy of the bufferis made otherwise no copy is made After the buffer is released the array contains noelements
buffer_ptr_tltTgt A unique_ptr with the data pointer
InvalidArrayTypeException
This TypedArray does not support releasing the buffer
matlabdataTypedArrayltTgt
1-113
ExamplesAssign Values to Array Elements
Create an array equivalent to the MATLAB array [1 2 3 4] then replace eachelement of the array with a single value
include MatlabDataArrayhpp
int main() matlabdataArrayFactory factory Create an array equivalent to the MATLAB array [1 2 3 4] matlabdataTypedArrayltdoublegt D = factorycreateArrayltdoublegt( 22 1324 ) Change the values for (autoamp elem D) elem = 55 return 0
bull ldquoBring Result of MATLAB Calculation Into C++rdquo
See AlsoArray | ArrayType
TopicsldquoBring Result of MATLAB Calculation Into C++rdquo
Introduced in R2017b
1 API Reference
1-114
matlabdataReferenceltTypedArrayltTgtgtC++ class to get reference to TypedArray
DescriptionThe ReferenceltTypedArrayltTgtgt class extends the APIs available to a reference to anArray It derives from the ReferenceltArraygt class and provides iterators and type-safe indexing ReferenceltTypedArrayltTgtgt is not thread-safe - do not pass referencesto TypedArray objects between threads
TypedArrayRef is defined in TypedArrayRefhpp as
template lttypename Tgtusing TypedArrayRef = ReferenceltTypedArrayltTgtgt
Class DetailsNamespace matlabdataBase class ReferenceltArraygtInclude TypedArrayRefhpp
ConstructorReference(const ReferenceltArraygtamp rhs)
Description
Create a ReferenceltTypedArrayltTgtgt object from a ReferenceltArraygt object
Parametersconst ReferenceltArraygtamprhs
Value to copy
matlabdataReferenceltTypedArrayltTgtgt
1-115
ThrowsTypeMismatchException Element of Array does not match ltTgt
Iteratorsbull ldquoBegin Interatorsrdquo on page 1-116bull ldquoEnd Iteratorsrdquo on page 1-116
Begin Interators
iterator begin()
const_iterator begin() const
const_iterator cbegin() const
iterator Iterator to beginning of array specified asTypedIteratorltTgt
const_iterator Iterator specified as TypedIteratorlttypenamestdadd_constltTgttypegt
None
End Iterators
iterator end()
const_iterator end() const
const_iterator cend() const
iterator Iterator to end of array specified asTypedIteratorltTgt
const_iterator Iterator specified as TypedIteratorlttypenamestdadd_constltTgttypegt
1 API Reference
1-116
None
Indexing Operators
operator[]ArrayElementTypedRefltarr_elem_type stdis_constltTgtvaluegtoperator[](size_t idx)
ArrayElementTypedRefltarr_elem_type truegt operator[](size_t idx)const
Enables [] indexing on a reference to an Array Indexing is 0-based
size_t idx First array index
ArrayElementTypedRefltarr_elem_typestdis_constltTgtvaluegt
Temporary object containing the index specified If typeT is const then the return value allows the element ofthe array to be retrieved but not modified Otherwisethe element can be modified or retrieved
ArrayElementTypedRefltarr_elem_type truegt
Temporary object containing the index specified Thereturn value allows the element of the array to beretrieved but not modified
InvalidFieldNameException
Field name is invalid for a struct
Other Operators
operator=ReferenceltTypedArrayltTgtgtamp operator= (TypedArrayltTgt rhs)
matlabdataReferenceltTypedArrayltTgtgt
1-117
Assign a TypedArray to an element of the referenced Array The Array being indexedmust be non-const
TypedArrayltTgt rhs Value to assign
ReferenceltTypedArrayltTgtgtamp
Updated instance
None
See Also
Introduced in R2017b
1 API Reference
1-118
matlabdataTypedIteratorltTgtTemplated C++ class to provide random access iterator
DescriptionTypedIterator is the return type of all begin and end functions that support randomaccess
Class DetailsNamespace matlabdataInclude TypedIteratorhpp
Template ParametersT Type of element referred to
Template Instantiationsdoublefloatint8_tuint8_tint16_tuint16_tint32_tuint32_tint64_tuint64_tchar16_tboolstdcomplexltdoublegt
matlabdataTypedIteratorltTgt
1-119
stdcomplexltfloatgtstdcomplexltint8_tgtstdcomplexltuint8_tgtstdcomplexltint16_tgtstdcomplexltuint16_tgtstdcomplexltint32_tgtstdcomplexltuint32_tgtstdcomplexltint64_tgtstdcomplexltuint64_tgtmatlabdataArraymatlabdataStructmatlabdataEnumerationmatlabdataMATLABString
Constructorsbull ldquoCopy Constructorsrdquo on page 1-120bull ldquoCopy Assignment Operatorsrdquo on page 1-121bull ldquoMove Constructorsrdquo on page 1-121bull ldquoMove Assignment Operatorsrdquo on page 1-121
Copy Constructors
TypedIterator(const TypedIteratorltTgtamp rhs)
Creates a shared data copy of a TypedIterator object
const TypedIteratorltTgtamprhs
Value to copy
None
1 API Reference
1-120
Copy Assignment OperatorsTypedIteratorltTgtamp operator=(const TypedIteratorltTgtamp rhs)
Assigns a shared data copy to a TypedIterator object
const TypedIteratorltTgtamprhs
Value to copy
TypedIteratorltTgtamp Updated instance
None
Move ConstructorsTypedIterator(TypedIteratorltTgt ampamprhs)
Moves contents of a TypedIterator object to a new instance
TypedIteratorltTgtampamp rhs Value to move
None
Move Assignment OperatorsTypedIteratorltTgtamp operator=(TypedIteratorltTgtampamp rhs)
Assigns the input to this TypedIterator object
TypedIteratorltTgtampamp rhs Value to move
TypedIteratorltTgtamp Updated instance
None
matlabdataTypedIteratorltTgt
1-121
Other Operatorsbull ldquooperator++rdquo on page 1-122bull ldquooperator--rdquo on page 1-122bull ldquooperator++rdquo on page 1-123bull ldquooperator--rdquo on page 1-123bull ldquooperator+=rdquo on page 1-123bull ldquooperator-=rdquo on page 1-124bull ldquooperator=rdquo on page 1-124bull ldquooperatorltrdquo on page 1-124bull ldquooperatorgtrdquo on page 1-125bull ldquooperatorlt=rdquo on page 1-125bull ldquooperatorgt=rdquo on page 1-125bull ldquooperator+rdquo on page 1-126bull ldquooperator-rdquo on page 1-126bull ldquooperator-rdquo on page 1-126bull ldquooperatorrdquo on page 1-127bull ldquooperator-gtrdquo on page 1-127bull ldquooperator[]rdquo on page 1-127
operator++TypedIteratorltTgtamp operator++()
Pre-increment operator
TypedIteratorltTgtamp Original iterator
None
operator--TypedIteratorltTgtamp operator--()
1 API Reference
1-122
Pre-decrement operator
TypedIteratorltTgtamp Original iterator
None
operator++TypedIteratorltTgt operator++(int)
Post-increment operator
TypedIteratorltTgt Copy of original iterator
None
operator--TypedIteratorltTgt operator--(int)
Post-decrement operator
TypedIteratorltTgt Copy of original iterator
None
operator+=TypedIteratorltTgtamp operator+=(difference_type d)
Addition assignment operator
difference_type d Amount to add specified as stdptrdiff_t
matlabdataTypedIteratorltTgt
1-123
TypedIteratorltTgtamp Updated instance
None
operator-=TypedIteratorltTgtamp operator-=(difference_type d)
Subtraction assignment operator
difference_type d Amount to subtract specified as stdptrdiff_t
TypedIteratorltTgtamp Updated instance
None
operator=bool operator=(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
bool Returns true if iterators do not point to same element
None
operatorltbool operatorlt(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
1 API Reference
1-124
bool Returns true if left-side iterator is less than right-sideiterator
operatorgtbool operatorgt(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
bool Returns true if left-side iterator is greater than right-side iterator
operatorlt=bool operatorlt=(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
bool Returns true if left-side iterator is less than or equal toright-side iterator
None
operatorgt=bool operatorgt=(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
bool Returns true if left-side iterator is greater than orequal to right-side iterator
None
matlabdataTypedIteratorltTgt
1-125
operator+TypedIteratorltTgt operator+(difference_type d) const
Creates an iterator that is added to this one by the amount passed in
difference_type d Amount to add specified as stdptrdiff_t
TypedIteratorltTgt Updated instance
None
operator-TypedIteratorltTgt operator-(difference_type d) const
Creates an iterator that is decremented from this one by the amount passed in
difference_type d Amount to subtract specified as stdptrdiff_t
TypedIteratorltTgt Updated instance
None
operator-difference_type operator-(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
difference_type Difference between iterators specified asstdptrdiff_t
None
1 API Reference
1-126
operatorreference operator() const
reference Element pointed to by this iterator specified as
bull Tamp for arithmetic typesbull ReferenceltTgt for non-arithmetic types
None
operator-gtpointer operator-gt()
pointer Pointer to element pointed to by this iterator specifiedas
bull T for arithmetic typesbull ReferenceltTgt for non-arithmetic types
None
operator[]reference operator[](const size_tamp rhs) const
Get a reference using a linear index
reference Element pointed to by this iterator specified as
bull Tamp for arithmetic typesbull ReferenceltTgt for non-arithmetic types
None
matlabdataTypedIteratorltTgt
1-127
Free Function
operator==bool operator==(const TypedIteratorltTgtamp rhs) const
const TypedIteratorltTgtamprhs
Iterator to compare
bool Returns true if both iterators point to same element
None
See Also
Introduced in R2017b
1 API Reference
1-128
matlabdataapply_visitorCall Visitor class on arrays
Descriptionauto apply_visitor(Array a V visitor) dispatch to visitor class operationsbased on array type
IncludeNamespace matlabdataInclude ArrayVisitorshpp
ParametersmatlabdataArray a
The matlabdataArray to operate on with the visitor class
visitor class V The user-supplied visitor class
Return Valueauto Outputs returned by the visitor
See Also
TopicsldquoOperate on C++ Arrays Using Visitor Patternrdquo
Introduced in R2017b
matlabdataapply_visitor
1-129
matlabdataapply_visitor_refCall Visitor class on array references
Descriptionauto apply_visitor_ref(const ArrayRefamp a V visitor) dispatch to visitorclass operations based on array reference type
IncludeNamespace matlabdataInclude ArrayVisitorshpp
ParametersconstmatlabdataArrayRefamp a
A matlabdataArrayRef reference to the array to operateon with the visitor class
visitor class V The user-supplied visitor class
Return Valueauto Outputs returned by the visitor
See Also
TopicsldquoOperate on C++ Arrays Using Visitor Patternrdquo
Introduced in R2017b
1 API Reference
1-130
matlabengineMATLABEngineEvaluate MATLAB functions from C++ program
DescriptionThe matlabengineMATLABEngine class uses a MATLAB process as acomputational engine for C++ This class provides an interface between the C++language and MATLAB enabling you to evaluate MATLAB functions and expressionsfrom C++ programs
Class DetailsNamespace matlabengineInclude MatlabEnginehpp
Factory MethodsThe matlabengineMATLABEngine class provides methods to start MATLAB and toconnect to a shared MATLAB session synchronously or asynchronously
bull matlabenginestartMATLAB mdash Start MATLAB synchronouslybull matlabenginestartMATLABAsync mdash Start MATLAB asynchronouslybull matlabengineconnectMATLAB mdash Connect to shared MATLAB session
synchronouslybull matlabengineconnectMATLABAsync mdash Connect to shared MATLAB session
asynchronously
Unsupported Startup OptionsThe engine does not support these MATLAB startup options
bull -h
matlabengineMATLABEngine
1-131
bull -helpbull -bull -nbull -ebull -softwareopenglbull -logfile
For information on MATLAB startup options see ldquoCommonly Used Startup OptionsrdquoFor an example of how to use MATLAB startup options when starting engineapplications see ldquoStart MATLAB with Startup Optionsrdquo
Method Summary
Member Functionsldquofevalrdquo on page 1-133
Evaluate MATLAB function with arguments synchronously
ldquofevalAsyncrdquo onpage 1-136
Evaluate MATLAB function with arguments asynchronously
ldquoevalrdquo on page 1-138 Evaluate MATLAB statement as a string synchronouslyldquoevalAsyncrdquo on page1-139
Evaluate MATLAB statement as a string asynchronously
ldquogetVariablerdquo onpage 1-140
Get variable from the MATLAB base workspace synchronously
ldquogetVariableAsyncrdquoon page 1-141
Get variable from the MATLAB base workspace asynchronously
ldquosetVariablerdquo onpage 1-142
Put variable into the MATLAB base workspace synchronously
ldquosetVariableAsyncrdquoon page 1-142
Put variable into the MATLAB base workspace asynchronously
ldquogetPropertyrdquo onpage 1-143
Get object property value
ldquogetPropertyAsyncrdquoon page 1-144
Get object property value asynchronously
1 API Reference
1-132
ldquosetPropertyrdquo onpage 1-145
Set object property value
ldquosetPropertyAsyncrdquoon page 1-146
Set object property value asynchronously
Member Function Details
fevalstdvectorltmatlabdataArraygt feval(const matlabengineString ampfunction const size_t numReturned const stdvectorltmatlabdataArraygt ampargs const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt() const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt())
matlabdataArray feval(const matlabengineString ampfunction const stdvectorltmatlabdataArraygt ampargs const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt() const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt())
matlabdataArray feval(const matlabengineString ampfunction const matlabdataArray amparg const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt() const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt())
ResultType feval(const matlabengineString ampfunction const stdshared_ptrltmatlabengineStreamBuffergt ampoutput const stdshared_ptrltmatlabengineStreamBuffergt amperror RhsArgsampamp rhsArgs )
ResultType feval(const matlabengineString ampfunction RhsArgsampamp rhsArgs)
Evaluate MATLAB functions with input arguments synchronously Use feval when youwant to pass arguments from C++ to MATLAB and when you want to return a resultfrom MATLAB to C++
Inputs and outputs can be types defined by the MATLAB Data Array API or can benative C++ types
constmatlabengineString ampfunction
Name of the MATLAB function or script to evaluate
matlabengineMATLABEngine
1-133
const size_tnumReturned
Number of returned values
conststdvectorltmatlabdataArraygt ampargs
Multiple input arguments to pass to the MATLAB function ina stdvector The vector is converted to a column array inMATLAB
constmatlabdataArrayarg
Single input argument to pass to the MATLAB function
conststdshared_ptrltmatlabengineStreamBuffergt ampoutput =stdshared_ptrltmatlabengineStreamBuffergt()
Stream buffer used to store the standard output from theMATLAB function
conststdshared_ptrltmatlabengineStreamBuffergt amperror =stdshared_ptrltmatlabengineStreamBuffergt()
Stream buffer used to store the error message from theMATLAB function
RhsArgsampamprhsArgs
Native C++ data types used for function inputs feval acceptsscalar inputs of these C++ data types bool int8_tint16_t int32_t int64_t uint8_t uint16_tuint32_t uint64_t float double
stdvectorltmatlabdataArraygt
Outputs returned from MATLAB function
matlabdataArray Single output returned from MATLAB functionResultType Output returned from MATLAB function as a user-specified
type Can be a stdtuple if returning multiple arguments
matlabengineMATLABNotAvailableException
The MATLAB session is not available
1 API Reference
1-134
matlabengineMATLABExecutionException
There is a MATLAB runtime error in the function
matlabengineTypeConversionException
The result of a MATLAB function cannot be converted tothe specified type
matlabengineMATLABSyntaxException
There is a syntax error in the MATLAB function
This example passes an array of numeric values to a MATLAB function The codeperforms these steps
bull Creates a matlabdataArray with the dimensions 2-by-3 from a vector ofnumeric values of type double
bull Starts a shared MATLAB sessionbull Passes the data array to the MATLAB sqrt function and returns the result to C++
include MatlabDataArrayhppinclude MatlabEnginehppusing namespace matlabengine
stdvectorltdoublegt cppData 4 8 12 16 20 24
Create a 2-by-3 matlab data array matlabdataArrayFactory factory auto inputArray = factorycreateArray( 2 3 cppDatacbegin() cppDatacend())
Start MATLAB engine stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()
Pass data array to MATLAB sqrt function And return results auto result = matlabPtr-gtfeval(usqrt inputArray)
When calling feval using native C++ types the input arguments are restricted to scalarvalues For example this code returns the square root of a scalar value
include MatlabEnginehppusing namespace matlabengine
Start MATLAB engine synchronously stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB() Call sqrt function double result = matlabPtr-gt fevalltdoublegt(usqrt double(27))
matlabengineMATLABEngine
1-135
For functions that return multiple output arguments you can use the MATLAB data APIor if using C++ types a stdtuple For an example see ldquoCall Function with Native C++ Typesrdquo
ldquoCall MATLAB Functions from C++rdquo
ldquoMATLAB Data APIrdquo
fevalAsyncFutureResultltstdvectorltmatlabdataArraygtgt fevalAsync(const matlabengineString ampfunction const size_t numReturned const stdvectorltmatlabdataArraygt ampargs const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt() const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt())
FutureResultltmatlabdataArraygt fevalAsync(const matlabengineString ampfunction const stdvectorltmatlabdataArraygt ampargs const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt() const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt())
FutureResultltmatlabdataArraygt fevalAsync(const matlabengineString ampfunction const matlabdataArray amparg const stdshared_ptrltmatlabengineStreamBuffergt amp output = stdshared_ptrltmatlabengineStreamBuffergt() const stdshared_ptrltmatlabengineStreamBuffergt amp error = stdshared_ptrltmatlabengineStreamBuffergt())
FutureResultltResultTypegt fevalAsync(const matlabengineString ampfunction const stdshared_ptrltmatlabengineStreamBuffergt ampoutput const stdshared_ptrltmatlabengineStreamBuffergt amperror RhsArgsampamp rhsArgs)
FutureResultltResultTypegt fevalAsync(const matlabengineString ampfunction RhsArgsampamp rhsArgs)
Evaluate MATLAB function with input arguments and returned values asynchronously
constmatlabengineString ampfunction
Name of the MATLAB function or script to evaluate
const size_tnumReturned
Number of returned values
conststdvectorltmatlabdataArraygt ampargs
Multiple input arguments to pass to the MATLAB function ina stdvector The vector is converted to a column array inMATLAB
1 API Reference
1-136
constmatlabdataArrayarg
Single input argument to pass to the MATLAB function
conststdshared_ptrltmatlabengineStreamBuffergt ampoutput =stdshared_ptrltmatlabengineStreamBuffergt()
Stream buffer used to store the standard output from theMATLAB function
conststdshared_ptrltmatlabengineStreamBuffergt amperror =stdshared_ptrltmatlabengineStreamBuffergt()
Stream buffer used to store the error message from theMATLAB function
RhsArgsampamprhsArgs
Native C++ data types used for function inputs feval acceptsscalar inputs of these C++ data types bool int8_tint16_t int32_t int64_t uint8_t uint16_tuint32_t uint64_t float double
FutureResult A FutureResult object used to get the result of calling theMATLAB function
None
This example passes the scalar double 127 to the MATLAB sqrt functionasynchronously The FutureResult is then used to get the result
include MatlabDataArrayhppinclude MatlabEnginehppusing namespace matlabenginestdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB() matlabdataArrayFactory factory matlabdataArray argument = factorycreateScalarltdoublegt(127) FutureResultltmatlabdataArraygt future = matlabPtr-gt fevalAsync(convertUTF8StringToUTF16String(sqrt) stdmove(argument))
matlabengineMATLABEngine
1-137
matlabdataTypedArrayltdoublegt result = futureget()
ldquoCall Function Asynchronouslyrdquo
evalvoid eval(const matlabengineString ampstatement const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt () const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt ())
Evaluate a MATLAB statement as a string synchronously
constmatlabengineString ampstatement
MATLAB statement to evaluate
conststdshared_ptrltmatlabengineStreamBuffergtampoutput
Stream buffer used to store the standard output from theMATLAB statement
conststdshared_ptrltmatlabengineStreamBuffergtamperror
Stream buffer used to store the error message from theMATLAB command
matlabengineMATLABNotAvailableException
The MATLAB session is not available
matlabengineMATLABExecutionException
There is a runtime error in the MATLAB statement
matlabengineMATLABSyntaxException
There is a syntax error in the MATLAB statement
This example evaluates the following MATLAB statement
a = sqrt(127)
1 API Reference
1-138
The statement creates the variable a in the MATLAB base workspace
include MatlabEnginehppusing namespace matlabenginestdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabPtr-gteval(convertUTF8StringToUTF16String(a = sqrt(127)))
ldquoEvaluate MATLAB Statements from C++rdquo
evalAsyncFutureResultltvoidgt evalAsync(const matlabengineString ampstr const stdshared_ptrltmatlabengineStreamBuffergt ampoutput = stdshared_ptrltmatlabengineStreamBuffergt () const stdshared_ptrltmatlabengineStreamBuffergt amperror = stdshared_ptrltmatlabengineStreamBuffergt ())
Evaluate a MATLAB statement as a string asynchronously
const Stringamp str MATLAB statement to evaluateconststdshared_ptrltmatlabengineStreamBuffergt ampoutput
Stream buffer used to store the standard output from theMATLAB statement
conststdshared_ptrltmatlabengineStreamBuffergt amperror
Stream buffer used to store the error message from theMATLAB command
FutureResult A FutureResult object used to wait for the completion of theMATLAB statement
None
This example evaluates the following MATLAB statement asynchronouslya = sqrt(127)
The statement creates the variable a in the MATLAB base workspace
matlabengineMATLABEngine
1-139
include MatlabEnginehppusing namespace matlabengine
stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()FutureResultltvoidgt future = matlabPtr-gt evalAsync(convertUTF8StringToUTF16String(a = sqrt(127)))
ldquoEvaluate MATLAB Statements from C++rdquo
getVariablematlabdataArray getVariable(const matlabengineString ampvarName WorkspaceType workspaceType = WorkspaceTypeBASE)
Get a variable from the MATLAB base or global workspace
constmatlabengineStringamp varName
Name of a variable in the MATLAB workspace
WorkspaceTypeworkspaceType =WorkspaceTypeBASE
MATLAB workspace (BASE or GLOBAL) to get the variablefrom For more information see global
matlabdataArray
Variable obtained from the MATLAB base or global workspace
matlabengineMATLABNotAvailableException
The MATLAB session is not available
matlabengineMATLABExecutionException
The requested variable does not exist in the specifiedMATLAB base or global workspace
This example gets a variable named varName from the MATLAB base workspace
include MatlabEnginehppusing namespace matlabenginestdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabdataArray varName = matlabPtr-gtgetVariable(convertUTF8StringToUTF16String(varName))
1 API Reference
1-140
ldquoPass Variables from MATLAB to C++rdquo
getVariableAsyncFutureResultltmatlabdataArraygt getVariableAsync(const matlabengineString ampvarName WorkspaceType workspaceType = WorkspaceTypeBASE)
Get a variable from the MATLAB base or global workspace asynchronously
constmatlabengineStringamp varName
Name of the variable in MATLAB workspace
WorkspaceTypeworkspaceType =WorkspaceTypeBASE
MATLAB workspace (BASE or GLOBAL) to get the variable fromFor more information see global
FutureResult A FutureResult object that you can use to get the variableobtained from the MATLAB workspace as amatlabdataArray
None
This example gets a variable named varName from the MATLAB base workspaceasynchronously
include MatlabEnginehppusing namespace matlabengine
stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()FutureResultltmatlabdataArraygt future = matlabPtr-gt getVariableAsync(convertUTF8StringToUTF16String(varName))matlabdataArray varName = futureget()
ldquoPass Variables from MATLAB to C++rdquo
matlabengineMATLABEngine
1-141
setVariablevoid setVariable(const matlabengineString ampvarName const matlabdataArray ampvar WorkspaceType workspaceType = WorkspaceTypeBASE)
Put a variable into the MATLAB base or global workspace If a variable with the samename exists in the MATLAB workspace setVariable overwrites it
constmatlabengineStringamp varName
Name of the variable to create in the MATLAB workspace
constmatlabdataArray var
Value of the variable to create in the MATLAB workspace
WorkspaceTypeworkspaceType =WorkspaceTypeBASE
Put the variable in the MATLAB BASE or GLOBAL workspaceFor more information see global
matlabengineMATLABNotAvailableException
The MATLAB session is not available
This example puts the variable named data in the MATLAB base workspace
include MatlabEnginehppusing namespace matlabenginestdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabdataArray data = factorycreateArrayltdoublegt( 1 3 4 8 6 )matlabPtr-gtsetVariable(convertUTF8StringToUTF16String(data) data)
ldquoPass Variables from C++ to MATLABrdquo
setVariableAsyncFutureResultltvoidgt setVariableAsync(const matlabengineString ampvarName const matlabdataArray var WorkspaceType workspaceType = WorkspaceTypeBASE)
1 API Reference
1-142
Put a variable into the MATLAB base or global workspace asynchronously If a variablewith the same name exists in the MATLAB base workspace setVariableAsyncoverwrites it
constmatlabengineStringamp varName
Name of the variable to create in the MATLAB workspace
constmatlabdataArray var
Value of the variable to create in the MATLAB workspace
WorkspaceTypeworkspaceType =WorkspaceTypeBASE
Put the variable in the MATLAB BASE or GLOBAL workspaceFor more information see global
None
This example puts the variable named data in the MATLAB base workspace
include MatlabEnginehppusing namespace matlabengine
stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabdataArray data = factorycreateArrayltdoublegt( 1 3 4 8 6 )FutureResultltvoidgt future = matlabPtr-gt setVariableAsync(convertUTF8StringToUTF16String(data) data)
ldquoPass Variables from MATLAB to C++rdquo
getPropertymatlabdataArray getProperty(const matlabdataArray ampobject const String amppropertyName)
Get the value of an object property
matlabengineMATLABEngine
1-143
constmatlabdataArray ampobject
MATLAB object
const StringamppropertyName
Name of the property
matlabdataArray
Value of the named property
matlabengineMATLABNotAvailableException
The MATLAB session is not available
matlabengineMATLABExecutionException
The property does not exist
This example evaluates a MATLAB statement in a trycatch block usingMATLABEngineeval The MATLABEnginegetVariable member function returnsthe exception object MATLABEnginegetProperty returns the exception messageproperty value as a matlabdataCharArray
include MatlabEnginehppusing namespace matlabengine
stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabPtr-gteval(convertUTF8StringToUTF16String(try surf(4) catch me end))matlabdataArray mException = matlabPtr-gt getVariable(convertUTF8StringToUTF16String(me))matlabdataCharArray message = matlabPtr-gt getProperty(mException convertUTF8StringToUTF16String(message))stdcout ltlt messages is ltlt messagetoAscii() ltlt stdendl
ldquoGet MATLAB Objects and Access Propertiesrdquo
getPropertyAsyncFutureResultltmatlabdataArraygt getPropertyAsync(const matlabdataArray ampobject const String amppropertyName)
Get the value of an object property asynchronously
1 API Reference
1-144
constmatlabdataArray ampobject
MATLAB object
const StringamppropertyName
Name of the property
FutureResult FutureResult object that is used to synchronize the operation
None
This example evaluates a MATLAB statement in a trycatch block usingMATLABEngineeval The MATLABEnginegetVariable member function returnsthe exception object MATLABEnginegetPropertyAsync returns a FutureResultthat you use to get the exception message property value as amatlabdataCharArray
include MatlabEnginehppusing namespace matlabengine
stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabPtr-gteval(convertUTF8StringToUTF16String(trysurf(4)catch meend))matlabdataArray mException = matlabPtr-gt getVariable(convertUTF8StringToUTF16String(me))FutureResultltmatlabdataArraygt future = matlabPtr-gt getPropertyAsync(mException convertUTF8StringToUTF16String(message))matlabdataCharArray message = futureget()stdcout ltlt messages is ltlt messagetoAscii() ltlt stdendl
ldquoGet MATLAB Objects and Access Propertiesrdquo
setPropertyvoid setProperty(matlabdataArray ampobject const String amppropertyName const matlabdataArray amppropertyValue)
Set the value of an object property
matlabdataArray ampobject
MATLAB object
matlabengineMATLABEngine
1-145
const StringamppropertyName
Name of the property to set
constmatlabdataArray amppropertyValue
Value assigned to the property
matlabengineMATLABNotAvailableException
The MATLAB session is not available
matlabengineMATLABExecutionException
The property does not exist
This example shows how to set a MATLAB object property It creates a MATLAB graphand returns the line handle object Setting the value of the line LineStyle property tothe character changes the property value of the line object in MATLAB and updates theline style of the graph
include MatlabEnginehppusing namespace matlabenginestdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabdataArrayFactory factorymatlabdataArray yData = factorycreateArrayltdoublegt( 1 5 40 110 47 362 723 )matlabdataArray lineHandle = matlabPtr-gtfeval(convertUTF8StringToUTF16String(plot) yData)matlabdataCharArray lineStyle = factorycreateCharArray()matlabPtr-gtsetProperty(lineHandle convertUTF8StringToUTF16String(LineStyle) lineStyle)
ldquoSet Property on MATLAB Objectrdquo
setPropertyAsyncFutureResultltvoidgt setPropertyAsync(matlabdataArray ampobject const String amppropertyName const matlabdataArray amppropertyValue)
Set the value of an object property asynchronously
matlabdataArray ampobject
MATLAB object
const StringamppropertyName
Name of the property to set
1 API Reference
1-146
constmatlabdataArray amppropertyValue
Value assigned to the property
None
This example shows how to set a MATLAB object property asynchronously It creates aMATLAB graph and returns the line handle object Setting the line LineStyle propertyto the character changes the property value of the object in MATLAB and updates theline style of the graph
include MatlabEnginehppusing namespace matlabenginestdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()matlabdataArrayFactory factorymatlabdataArray yData = factorycreateArrayltdoublegt( 1 5 40 110 47 362 723 )matlabdataArray lineHandle = matlabPtr-gtfeval(convertUTF8StringToUTF16String(plot) yData)matlabdataCharArray lineStyle = factorycreateCharArray() FutureResultltvoidgt future = matlabPtr-gt setPropertyAsync(lineHandle convertUTF8StringToUTF16String(LineStyle) lineStyle)
ldquoSet Property on MATLAB Objectrdquo
See Also
Introduced in R2017b
matlabengineMATLABEngine
1-147
matlabengineconnectMATLABConnect to shared MATLAB session synchronously
Descriptionstdunique_ptrltMATLABEnginegt connectMATLAB()
stdunique_ptrltMATLABEnginegt connectMATLAB(constmatlabengineStringamp name)
Connect synchronously to a shared MATLAB session on the local machine
bull If you specify the name of a shared MATLAB session but the engine cannot find asession with that name the engine throws an exception
bull If you do not specify a name and there is no shared MATLAB session available theengine starts a new shared MATLAB session The MATLAB desktop is not started
bull If you do not specify a name and there are shared MATLAB sessions available theengine connects to the first available session
IncludeNamespace matlabengineInclude MatlabEnginehpp
ParametersconstmatlabengineStringamp name
Name of the shared MATLAB session
1 API Reference
1-148
Return Valuestdunique_ptrltMATLABEnginegt
Pointer to a MATLABEngine object
ExceptionsmatlabengineEngineException
Throws exception if function fails to connect to the specified MATLABsession
Examples
Connect to Shared MATLAB Session
Connect to a shared MATLAB session named my_matlab
stdunique_ptrltMATLABEnginegt matlabPrt = connectMATLAB(convertUTF8StringToUTF16String(my_matlab))
bull ldquoStart MATLAB Sessions from C++rdquo
See AlsomatlabengineconnectMatlabAsync
TopicsldquoStart MATLAB Sessions from C++rdquo
Introduced in R2017b
matlabengineconnectMATLAB
1-149
matlabengineconnectMATLABAsyncConnect to shared MATLAB session asynchronously
DescriptionFutureResultltstdunique_ptrltMATLABEnginegtgt connectMATLABAsync()
FutureResultltstdunique_ptrltMATLABEnginegtgt connectMATLABAsync(constmatlabengineStringamp name)
Connect asynchronously to a shared MATLAB session on the local machine
bull If you specify the name of a shared MATLAB session but the engine cannot find asession with that name the engine throws an exception
bull If you do not specify a name and there is no shared MATLAB session available theengine starts a new shared MATLAB session The MATLAB desktop is not started
bull If you do not specify a name and there are shared MATLAB sessions available theengine connects to the first available session
IncludeNamespace matlabengineInclude MatlabEnginehpp
ParametersconstmatlabengineStringamp name
Name of the shared MATLAB session
1 API Reference
1-150
Return ValueFutureResultltstdunique_ptrltMATLABEnginegtgt
A FutureResult object that you can use to get the pointer to theMATLABEngine
Examples
Connect to Shared MATLAB Session Asynchronously
Connect to a shared MATLAB session named my_matlab asynchronously Use theFutureResult get method to retrieve the pointer to the MATLABEngine objectFutureResultsltstdunique_ptrltMATLABEnginegtgt future = connectMATLABAsync(convertUTF8StringToUTF16String(my_matlab))stdunique_ptrltMATLABEnginegt matlabPtr = futureget()
bull ldquoConnect C++ to Running MATLAB Sessionrdquo
See AlsomatlabengineconnectMatlab
TopicsldquoConnect C++ to Running MATLAB Sessionrdquo
Introduced in R2017b
matlabengineconnectMATLABAsync
1-151
matlabengineconvertUTF8StringToUTF16StringConvert UTF-8 string to UTF-16 string
Descriptionstdbasic_stringltchar16_tgt convertUTF8StringToUTF16String(conststdstringamp utf8string)
Convert a UTF-8 string to a UTF-16 string Use this function to convert ASCII strings tomatlabengineString strings which are required by MATLAB C++ Enginefunctions
IncludeNamespace matlabengineInclude MatlabEnginehpp
Parametersconststdstringamputf8string
A UTF-8 string
Return Valuestdbasic_stringltchar16_tgt
A UTF-16 string
ExceptionsmatlabengineOutofMemoryException
The function failed to allocate memory
1 API Reference
1-152
matlabengineTypeConversionException
The input type cannot be converted tostdbasic_stringltchar16_tgt
Examples
Convert String
Convert a UTF-8 string to a matlabengineString (UTF-16 string)
matlabengineString matlabStatement = convertUTF8StringToUTF16String(sqrt(127))
See AlsomatlabengineString |matlabengineconvertUTF16StringToUTF8String
Introduced in R2017b
matlabengineconvertUTF8StringToUTF16String
1-153
matlabengineconvertUTF16StringToUTF8StringConvert UTF-16 string to UTF-8 string
Descriptionstdstring convertUTF16StringToUTF8String(conststdbasic_stringltchar16_tgtamp utf16string)
Convert a UTF-16 string to a UTF-8 string
IncludeNamespace matlabengineInclude MatlabEnginehpp
Parametersconststdbasic_stringltchar16_tgtamputf16string
A UTF-16 string
Return Valuestdstring A UTF-8 string
ExceptionsmatlabengineOutofMemoryException
The function failed to allocate memory
1 API Reference
1-154
matlabengineTypeConversionException
The input type cannot be converted to stdstring
Examples
Convert String
Convert a matlabengineString (UTF-16 string) to a stdstring (UTF-8string)
matlabengineString matlabStatement = (usqrt(127))stdstring cmdString = convertUTF16StringToUTF8String(matlabStatement)
See AlsomatlabengineString |matlabengineconvertUTF8StringToUTF16String
Introduced in R2017b
matlabengineconvertUTF16StringToUTF8String
1-155
matlabenginefindMATLABFind shared MATLAB sessions synchronously
DescriptionstdvectorltStringgt findMATLAB()
Find all shared MATLAB sessions on the local machine
IncludeNamespace matlabengineInclude MatlabEnginehpp
ParametersNone
Return ValuestdvectorltStringgt
A vector of the names of all shared MATLAB sessions on the localmachine or an empty vector if no shared MATLAB sessions areavailable
ExceptionsmatlabengineEngineException
Throws exception if the call fails while searching for shared MATLABsessions
Examples
1 API Reference
1-156
Find Shared MATLAB Session Synchronously
stdvectorltStringgt names = findMATLAB()
See AlsomatlabenginefindMATLABAsync
Introduced in R2017b
matlabenginefindMATLAB
1-157
matlabenginefindMATLABAsyncFind shared MATLAB sessions asynchronously
DescriptionFutureResultltstdvectorltStringgtgt findMATLABAsync()
Find all shared MATLAB sessions on the local machine asynchronously
IncludeNamespace matlabengineInclude MatlabEnginehpp
ParametersNone
Return ValueFutureResultltstdvectorltStringgtgt
A FutureResult object that you can use to get the names of sharedMATLAB sessions on the local machine
Examples
Find Shared MATLAB Session Asynchronously
Find the names of all shared MATLAB sessions on the local machine asynchronouslyUse the FutureResult get method to retrieve the names
1 API Reference
1-158
FutureResultltstdvectorltStringgtgt futureNames = findMATLABAsync()stdvectorltStringgt matlabSessions = futureNamesget()
See AlsomatlabenginefindMATLAB
Introduced in R2017b
matlabenginefindMATLABAsync
1-159
matlabengineFutureResultRetrieve result from asynchronous operation
DescriptionA future result is an object that you can use to retrieve the result of MATLAB functionsor statements The FutureResult class provides all member functions of the C++stdfuture class
Class DetailsNamespace matlabengineInclude MatlabEnginehpp
Constructor SummaryCreate a FutureResult object using these asynchronous functions
bull Asynchronous member functions defined by matlabengineMATLABEnginebull matlabenginestartMATLABAsync
matlabengineconnectMATLABAsync andmatlabenginefindMATLABAsync
Method Summary
Member Functionsldquocancelrdquo on page 1-161
Cancel the operation held by the FutureResult object
Member Functions Delegated to stdfutureoperator= share get wait wait_for wait_until
1 API Reference
1-160
matlabengineEngineException
Cannot start or connect to MATLAB session
matlabengineCancelException
Execution of command is canceled
matlabengineInterruptedException
Evaluation of command is interrupted
matlabengineMATLABNotAvailableException
The MATLAB session is not available
matlabengineMATLABSyntaxException
There is a syntax error in the MATLAB function
matlabengineMATLABExecutionException
MATLAB runtime error in the function
matlabengineTypeConversionException
The result from a MATLAB function cannot be convertedto the specified type
Method Details
cancelbool FutureResultcancel(bool allowInterrupt = true)
Cancel the evaluation of the MATLAB function or statement You cannot cancelasynchronous operations that use matlabenginestartMATLABAsyncmatlabengineconnectMATLABAsync or matlabenginefindMATLABAsync
boolallowInterrupt
If false do not interrupt if execution had already begun
bool Was command canceled if execution had already begun
bool flag = futurecancel()
No exceptions thrown
matlabengineFutureResult
1-161
See Also
TopicsldquoCall Function Asynchronouslyrdquo
Introduced in R2017b
1 API Reference
1-162
matlabenginestartMATLABStart MATLAB synchronously
Descriptionstdunique_ptrltMATLABEnginegt startMATLAB(const stdvectorltStringgtampoptions = stdvectorltStringgt())
Start MATLAB synchronously in a separate process with optional MATLAB startupoptions
IncludeNamespace matlabengineInclude MatlabEnginehpp
ParametersconststdvectorltStringgtampoptions
Options used to start MATLAB See ldquoSpecify Startup Optionsrdquo
Return Valuestdunique_ptrltMATLABEnginegt
Pointer to the MATLABEngine object
matlabenginestartMATLAB
1-163
ExceptionsmatlabengineEngineException
MATLAB failed to start
Examples
Start MATLAB Synchronously
Start MATLAB synchronously and return a unique pointer to the MATLABEngine object
stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB()
Start MATLAB with Startup Options
Start MATLAB with the -nojvm option and return a unique pointer to theMATLABEngine object
stdvectorltStringgt optionVecoptionVecpush_back(convertUTF8StringToUTF16String(-nojvm))stdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB(optionVec)
bull ldquoStart MATLAB Sessions from C++rdquo
See AlsomatlabengineMATLABEngine | matlabenginestartMATLABAsync
TopicsldquoStart MATLAB Sessions from C++rdquo
Introduced in R2017b
1 API Reference
1-164
matlabenginestartMATLABAsyncStart MATLAB asynchronously
DescriptionFutureResultltstdunique_ptrltMATLABEnginegtgt startMATLABAsync(conststdvectorltStringgtamp options = stdvectorltStringgt())
Start MATLAB asynchronously in a separate process with optional MATLAB startupoptions
IncludeNamespace matlabengineInclude MatlabEnginehpp
ParametersconststdvectorltStringgtamp options
Startup options used to launch MATLAB
Return ValueFutureResultltstdunique_ptrltMATLABEnginegtgt
A FutureResult object used to get the pointer to theMATLABEngine
Examples
matlabenginestartMATLABAsync
1-165
Start MATLAB Asynchronously
Start MATLAB asynchronously and return a FutureResult object Use theFutureResult to get a pointer to the MATLABEngine objectFutureResultltstdunique_ptrltMATLABEnginegtgt matlabFuture = startMATLAB()stdunique_ptrltMATLABEnginegt matlabPtr = matlabFutureget()
bull ldquoSpecify Startup Optionsrdquo
See AlsomatlabenginestartMATLAB
TopicsldquoSpecify Startup Optionsrdquo
Introduced in R2017b
1 API Reference
1-166
matlabengineterminateEngineClientFree engine resources during runtime
Descriptionvoid matlabengineterminateEngineClient releases all MATLAB engineresources during runtime when you no longer need the MATLAB engine in yourapplication program
Note Programs cannot start a new MATLAB engine or connect to a shared MATLABsession after calling terminateEngineClient
IncludeNamespace matlabengineInclude MatlabEnginehpp
ExamplesTerminate the engine session to free resources Start MATLAB sessionstdunique_ptrltMATLABEnginegt matlabPtr = startMATLAB() Terminate MATLAB sessionmatlabengineterminateEngineClient()
See AlsomatlabenginestartMATLAB
Introduced in R2017b
matlabengineterminateEngineClient
1-167
matlabengineWorkspaceTypeType of MATLAB workspace
DescriptionThe matlabengineWorkspaceType enum class specifies the MATLAB workspaceto pass variables to or get variables fromBASE Variables scoped to the MATLAB base workspace
(command line and nonfunction scripts)GLOBAL Variables scoped to the MATLAB global workspace
(command line functions and scripts)
MATLAB scopes variables by workspace Variables that are scoped to the baseworkspace must be passed to functions as arguments Variables scoped to the globalworkspace can be accessed by any function that defines the specific variable name asglobal
Class DetailsNamespace matlabengineInclude MatlabEnginehpp
ExamplesThis example
bull Connects to a shared MATLAB sessionbull Creates a matlabdataArray containing numeric values of type doublebull Puts the array in the MATLAB global workspaceinclude MatlabDataArrayhppinclude MatlabEnginehppinclude ltiostreamgt
static void putGlobalVar()
1 API Reference
1-168
using namespace matlabengine
Connect to named shared MATLAB session started as matlab -r matlabengineshareEngine(myMatlabEngine) String session(convertUTF8StringToUTF16String(myMatlabEngine)) stdunique_ptrltMATLABEnginegt matlabPtr = connectMATLAB(session)
Create matlab data array factory matlabdataArrayFactory factory
Create data variable matlabdataArray data = factorycreateArrayltdoublegt ( 1 5 40 110 47 362 723 )
Put data variable in MATLAB global workspace matlabPtr-gtsetVariable(convertUTF8StringToUTF16String(data) data WorkspaceTypeGLOBAL)
See AlsomatlabdataArrayFactory | matlabengineMATLABEngine |matlabengineconvertUTF8StringToUTF16String
TopicsldquoPass Variables from C++ to MATLABrdquoldquoPass Variables from MATLAB to C++rdquo
Introduced in R2017b
matlabengineWorkspaceType
1-169
matlabengineStringDefine UTF16 string
DescriptionType definition for stdbasic_stringltchar16_tgt
ExamplesThis example defines a variable containing the name of a shared MATLAB session Passthis string to the matlabengineconnectMATLAB function to connect to the namedsessionmatlabengineString session(convertUTF8StringToUTF16String(myMatlabEngine)) stdunique_ptrltMATLABEnginegt matlabPtr = connectMATLAB(session)
See AlsomatlabengineconvertUTF16StringToUTF8String |matlabengineconvertUTF8StringToUTF16String
TopicsldquoMATLAB Engine API for C++rdquoldquoConnect C++ to Running MATLAB Sessionrdquo
Introduced in R2017b
1 API Reference
1-170
matlabengineStreamBufferDefine stream buffer
DescriptionType definition for stdbasic_streafbufltchar16_tgt
ExamplesThis example defines string buffers to return output from the evaluation of a MATLABfunction by the MATLABEngineeval member function This function uses a bufferderived from matlabengineStreamBuffer to return output from MATLAB to C++include MatlabEnginehppinclude MatlabDataArrayhppinclude ltiostreamgt
using namespace matlabengineusing SBuf = stdbasic_stringbufltchar16_tgt
void printFromBuf(const stdshared_ptrltSBufgt buf) Get text from buf auto text_ = buf-gtstr() stdcout ltlt ltlt convertUTF16StringToUTF8String(text_) ltlt ltlt stdendl
int main()
Create Array factory matlabdataArrayFactory factory
Connect to named shared MATLAB session started as matlab -r matlabengineshareEngine(myMatlabEngine) String session(convertUTF8StringToUTF16String(myMatlabEngine)) stdunique_ptrltMATLABEnginegt matlabPtr = connectMATLAB(session)
auto outBuf = stdmake_sharedltSBufgt() auto errBuf = stdmake_sharedltSBufgt()
matlabPtr-gteval(convertUTF8StringToUTF16String(matlabengineengineName) outBuf errBuf) printFromBuf(outBuf) printFromBuf(errBuf) return 0
matlabengineStreamBuffer
1-171
See AlsomatlabengineconnectMATLAB |matlabengineconvertUTF16StringToUTF8String |matlabengineconvertUTF8StringToUTF16String
TopicsldquoRedirect MATLAB Command Window Output to C++rdquo
Introduced in R2017b
1 API Reference
1-172
matlabengineSharedFutureResultRetrieve result from asynchronous operation as shared future
DescriptionA shared future result is an object that you use to retrieve the result of MATLABfunctions or statements any number of times
Class DetailsNamespace matlabengineInclude MatlabEnginehpp
Constructor SummaryCreate a FutureResult object using one of these asynchronous functions
bull Asynchronous member functions defined by matlabengineMATLABEnginebull matlabenginestartMATLABAsync
matlabengineconnectMATLABAsync andmatlabenginefindMATLABAsync
Method Summary
Member Functionsldquocancelrdquo on page 1-161
Cancel the operation held by the FutureResult object
Member Function Delegated to stdshared_futureoperator= get valid wait wait_for wait_until
matlabengineSharedFutureResult
1-173
matlabengineEngineException
Cannot start or connect to MATLAB session
matlabengineCancelException
Execution of command is canceled
matlabengineInterruptedException
Evaluation of command is interrupted
matlabengineMATLABNotAvailableException
The MATLAB session is not available
matlabengineMATLABSyntaxException
There is a syntax error in the MATLAB function
matlabengineMATLABExecutionException
MATLAB runtime error in the function
matlabengineTypeConversionException
The result from a MATLAB function cannot be convertedto the specified type
Method Details
cancelbool FutureResultcancel(bool allowInterrupt = true)
Cancel the evaluation of the MATLAB function or statement
Note that you cannot cancel asynchronous start connection or find operations which areinitiated using these functions matlabenginestartMATLABAsyncmatlabengineconnectMATLABAsync or matlabenginefindMATLABAsync
boolallowInterrupt
If false do not interrupt if execution has already begun
bool True if the MATLAB command can be canceled
bool flag = futurecancel()
None
1 API Reference
1-174
See AlsomatlabengineFutureResult
TopicsldquoCall Function Asynchronouslyrdquo
Introduced in R2017b
matlabengineSharedFutureResult
1-175
commathworksengineMatlabEngine classPackage commathworksengine
Java class using MATLAB as a computational engine
DescriptionThe commathworksengineMatlabEngine class uses a MATLAB process as acomputational engine for Javareg This class provides an interface between the Javalanguage and MATLAB enabling you to evaluate MATLAB functions and expressionsfrom Java
Constructor SummaryThe MatlabEngine class provides static methods to start MATLAB and to connect to ashared MATLAB session synchronously or asynchronously Only these static methodscan instantiate this class
bull Start MATLAB synchronously mdash ldquostartMatlabrdquo on page 1-178bull Connect to shared MATLAB session synchronously mdash ldquoconnectMatlabrdquo on page 1-180bull Start MATLAB asynchronously mdash ldquostartMatlabAsyncrdquo on page 1-179bull Connect to shared MATLAB session asynchronously mdash ldquoconnectMatlabAsyncrdquo on
page 1-181
Unsupported Startup OptionsThe engine does not support these MATLAB startup options
bull -hbull -helpbull -bull -n
1 API Reference
1-176
bull -ebull -softwareopenglbull -logfile
For information on MATLAB startup options see ldquoCommonly Used Startup Optionsrdquo
Method Summary
Static MethodsldquostartMatlabrdquo onpage 1-178
Start MATLAB synchronously
ldquostartMatlabAsyncrdquoon page 1-179
Start MATLAB asynchronously
ldquofindMatlabrdquo onpage 1-179
Find all available shared MATLAB sessions from a local machinesynchronously
ldquofindMatlabAsyncrdquoon page 1-180
Find all available shared MATLAB sessions from a local machineasynchronously
ldquoconnectMatlabrdquo onpage 1-180
Connect to a shared MATLAB session on a local machinesynchronously
ldquoconnectMatlabAsyncrdquo on page 1-181
Connect to a shared MATLAB session on a local machineasynchronously
Member VariableNULL_WRITER Use a writer that ignores the contents from the MATLAB
command window
Member Functionsldquofevalrdquo on page 1-182
Evaluate a MATLAB function with arguments synchronously
ldquofevalAsyncrdquo onpage 1-183
Evaluate a MATLAB function with arguments asynchronously
ldquoevalrdquo on page 1-184 Evaluate a MATLAB expression as a string synchronously
commathworksengineMatlabEngine class
1-177
ldquoevalAsyncrdquo on page1-185
Evaluate a MATLAB expression as a string asynchronously
ldquogetVariablerdquo onpage 1-186
Get a variable from the MATLAB base workspace synchronously
ldquogetVariableAsyncrdquoon page 1-187
Get a variable from the MATLAB base workspace asynchronously
ldquoputVariablerdquo onpage 1-187
Put a variable into the MATLAB base workspace synchronously
ldquoputVariableAsyncrdquoon page 1-188
Put a variable into the MATLAB base workspace asynchronously
ldquodisconnectrdquo on page1-188
Disconnect from the current MATLAB session synchronously
ldquodisconnectAsyncrdquoon page 1-189
Disconnect from the current MATLAB session asynchronously
ldquoquitrdquo on page 1-189 Force the shutdown of the current MATLAB sessionsynchronously
ldquoquitAsyncrdquo on page1-189
Force the shutdown of the current MATLAB sessionasynchronously
ldquocloserdquo on page 1-190
Disconnect or terminate the current MATLAB session
Method Details
startMatlabstatic MatlabEngine startMatlab(String[] options)
static MatlabEngine startMatlab()
Start MATLAB synchronously
String[] options Startup options used to start MATLAB engine For options seeldquoStartup and Shutdownrdquo
1 API Reference
1-178
Instance of MatlabEngine
commathworksengineEngineException
MATLAB fails to start
MatlabEngine engine = MatlabEnginestartMatlab()
ldquoStart and Close MATLAB Session from Javardquo
startMatlabAsyncstatic FutureltMatlabEnginegt startMatlabAsync(String[] options)
static FutureltMatlabEnginegt startMatlabAsync()
Start MATLAB asynchronously
String[] options Startup options used to start MATLAB For options seeldquoStartup and Shutdownrdquo
Instance of FutureltMatlabEnginegt
FutureltMatlabEnginegt future = MatlabEnginestartMatlabAsync()
ldquoStart and Close MATLAB Session from Javardquo
findMatlabstatic String[] findMatlab()
Find all shared MATLAB sessions on the local machine synchronously
commathworksengineMatlabEngine class
1-179
An array of the names of all shared MATLAB sessions on the local machine or an emptyvector if there are no shared MATLAB sessions available on the local machine
commathworksengineEngineException
If there is a failure during the search for MATLAB sessions
String[] engines = MatlabEnginefindMatlab()
ldquoConnect Java to Running MATLAB Sessionrdquo
findMatlabAsyncstatic FutureltSting[]gt findMatlabAsync()
Find all shared MATLAB sessions on local machine asynchronously
An instance of FutureltString[]gt
FutureltString[]gt future = MatlabEnginefindMatlabAsync()
ldquoConnect Java to Running MATLAB Sessionrdquo
connectMatlabstatic MatlabEngine connectMatlab(String name)
static MatlabEngine connectMatlab()
Connect to a shared MATLAB session on local machine synchronously
bull If you specify the name of a shared MATLAB session but the engine cannot find asession with that name the engine throws an exception
bull If you do not specify a name and there is no shared MATLAB session available theengine starts a new shared MATLAB session with default options
1 API Reference
1-180
bull If you do not specify a name and there are shared MATLAB sessions available theengine connects to the first available session
String name Name of the shared MATLAB session Use ldquofindMatlabrdquo on page1-179 to get the names of shared MATLAB sessions
An instance of MatlabEngine
commathworksengineEngineException
MATLAB fails to start or connect
MatlabEngine engine = MatlabEngineconnectMatlab()
ldquoConnect Java to Running MATLAB Sessionrdquo
connectMatlabAsyncstatic FutureltMatlabEnginegt connectMatlabAsync(String name)
static FutureltMatlabEnginegt connectMatlabAsync
Connect to a shared MATLAB session on local machine asynchronously The behavior isthe same as that of connectMatlab except the mechanism is asynchronous
String name Name of the shared MATLAB session
An instance of FutureltMatlabEnginegt
FutureltMatlabEnginegt future = MatlabEngineconnectMatlabAsync()
ldquoConnect Java to Running MATLAB Sessionrdquo
commathworksengineMatlabEngine class
1-181
fevalltTgt T feval(int nlhs String func Writer output Writer errorObjecthellip args)
ltTgt T feval(int nlhs String func Objecthellip args)
ltTgt T feval(String func Writer output Writer error Objecthellip args)
ltTgt T feval(String func Objecthellip args)
Evaluate MATLAB functions with input arguments synchronously
String func Name of the MATLAB function or script to evaluateint nlhs Number of expected outputs Default is 1
If nlhs is greater than 1 the returned type T must beltObject[]gt
If nlhs is 0 the returned type T must be ltVoidgt or ltgt
If nlhs is 1 the returned type T can be the expected type orltObjectgt if the type is not known
Writer output Stream used to store the standard output from the MATLABfunction If you do not specify a writer the output is written tothe command window or terminal Use NULL_WRITER to ignorethe output from the MATLAB command window
Writer error Stream used to store the standard error from the MATLABfunction If you do not specify a writer the output is written tothe command window or terminal Use NULL_WRITER to ignorethe error message from the MATLAB command window
Object args Arguments to pass to the MATLAB function
Result of executing the MATLAB function
javautilconcurrentCancellationException
Evaluation of a MATLAB function was canceled
1 API Reference
1-182
javalangInterruptedException
Evaluation of a MATLAB function was interrupted
javalangIllegalStateException
The MATLAB session is not available
commathworksengineMatlabExcecutionException
There is a MATLAB runtime error in the function
commathworksengineUnsupportedTypeExeption
There is an unsupported data type
commathworksengineMatlabSyntaxException
There is a syntax error in the MATLAB function
double result = enginefeval(sqrt 4)
ldquoExecute MATLAB Functions from Javardquo
fevalAsyncltTgt FutureltTgt fevalAsync(int nlhs String func Writer outputWriter error Objecthellip args)
ltTgt FutureltTgt fevalAsync(int nlhs String func Objecthellip args)
ltTgt FutureltTgt fevalAsync(String func Writer output Writer errorObjecthellip args)
ltTgt FutureltTgt fevalAsync(String func Objecthellip args)
Evaluate MATLAB functions with input arguments asynchronously
String func Name of the MATLAB function or script to evaluate
commathworksengineMatlabEngine class
1-183
int nlhs Number of expected outputs Default is 1
If nlhs is greater than 1 the returned type T must beltObject[]gt
If nlhs is 0 the returned type T must be ltVoidgt or ltgt
If nlhs is 1 the returned type T can be the expected type orltObjectgt if the type is not known
Writer output Stream used to store the standard output from the MATLABfunction If you do not specify a writer the output is written tothe command window or terminal Use NULL_WRITER to ignorethe output from the MATLAB command window
Writer error Stream used to store the standard error from the MATLABfunction If you do not specify a writer the output is written tothe command window or terminal Use NULL_WRITER to ignorethe error message from the MATLAB command window
Object args Arguments to pass to the MATLAB function
An instance of FutureltTgt
javalangIllegalStateException
The MATLAB session is not available
FutureltDoublegt future = enginefevalAsync(sqrt 4)
ldquoExecute MATLAB Functions from Javardquo
evalvoid eval(String command Writer output Writer error)
void eval(String command)
Evaluate a MATLAB statement as a string synchronously
1 API Reference
1-184
String command MATLAB statement to evaluateWriter output Stream used to store the standard output from the MATLAB
statement If you do not specify a writer the output is written tothe command window or terminal Use NULL_WRITER to ignorethe output from the MATLAB command window
Writer error Stream used to store the standard error from the MATLABstatement If you do not specify a writer the output is written tothe command window or terminal Use NULL_WRITER to ignorethe error message from the MATLAB command window
javautilconcurrentCancellationException
Evaluation of a MATLAB function was canceled
javalangInterruptedException
Evaluation of a MATLAB function was interrupted
javalangIllegalStateException
The MATLAB session is not available
commathworksengineMatlabExcecutionException
There is an error in the MATLAB statement duringruntime
commathworksengineMatlabSyntaxException
There is a syntax error in the MATLAB statement
engineeval(result = sqrt(4))
ldquoEvaluate MATLAB Statements from Javardquo
evalAsyncFutureltVoidgt evalAsync(String command Writer output Writer error)
FutureltVoidgt evalAsync(String command)
Evaluate a MATLAB statement as a string asynchronously
String command MATLAB statement to evaluate
commathworksengineMatlabEngine class
1-185
Writer output Stream used to store the standard output from theMATLAB statement If you do not specify a writer theoutput is written to the command window or terminal UseNULL_WRITER to ignore the output from the MATLABcommand window
Writer error Stream used to store the standard error from theMATLAB statement If you do not specify a writer theoutput is written to the command window or terminal UseNULL_WRITER to ignore the error message from theMATLAB command window
An instance of FutureltVoidgt
javalangIllegalStateException
The MATLAB session is not available
FutureltVoidgt future = engineevalAsync(sqrt(4))
ldquoEvaluate MATLAB Statements from Javardquo
getVariableltTgt T getVariable(String varName)
Get a variable from the MATLAB base workspace
String varName Name of a variable in the MATLAB base workspace
Variable passed from the MATLAB base workspace
javautilconcurrentCancellationException
Evaluation of this function is canceled
javalangInterruptedException
Evaluation of this function is interrupted
1 API Reference
1-186
javalangIllegalStateException
The MATLAB session is not available
double myVar = enginegetVariable(myVar)
ldquoPass Variables from MATLAB to Javardquo
getVariableAsyncltTgt FutureltTgt getVariableAsync(String varName)
Get a variable from the MATLAB base workspace asynchronously
String varName Name of a variable in MATLAB base workspace
An instance of FutureltTgt
javalangIllegalStateException
The MATLAB session is not available
FutureltDoublegt future = enginegetVariableAsync(myVar)
ldquoPass Variables from MATLAB to Javardquo
putVariablevoid putVariable(String varName T varData)
Put a variable into the MATLAB base workspace
String varName Name of a variable to create in the MATLAB base workspaceT varData Value of the variable to create in the MATLAB base workspace
commathworksengineMatlabEngine class
1-187
javautilconcurrentCancellationException
Evaluation of this function is canceled
javalangInterruptedException
Evaluation of this function is interrupted
javalangIllegalStateException
The MATLAB session is not available
engineputVariable(myVar 100)
ldquoPass Variables from Java to MATLABrdquo
putVariableAsyncFutureltVoidgt putVariableAsync(String varName T varData)
Put a variable into the MATLAB base workspace asynchronously
String varName Name of a variable to create in the MATLAB base workspaceT varData Value of the variable to create in the MATLAB base workspace
An instance of FutureltVoidgt
javalangIllegalStateException
The MATLAB session is not available
FutureltVoidgt future = engineputVariableAsync(myVar 100)
ldquoPass Variables from Java to MATLABrdquo
disconnectvoid disconnect()
Disconnect from the current MATLAB session
1 API Reference
1-188
commathworksengineEngineException
The current MATLAB session cannot be disconnected
enginedisconnect()
ldquoClose MATLAB Engine Sessionrdquo
disconnectAsyncFutureltVoidgt disconnectAsync()
Disconnect from the current MATLAB session
FutureltVoidgt future = enginedisconnectAsync()
ldquoClose MATLAB Engine Sessionrdquo
quitviod quit()
Force the shutdown of the current MATLAB session
commathworksengineEngineException
The current MATLAB session cannot be shut down
enginequit()
ldquoClose MATLAB Engine Sessionrdquo
quitAsyncFutureltVoidgt quitAsync()
commathworksengineMatlabEngine class
1-189
Force the shutdown of the current MATLAB session asynchronously without waiting fortermination
An instance of FutureltVoidgt
FutureltVoidgt future = enginequitAsync()
ldquoClose MATLAB Engine Sessionrdquo
closevoid close()
MatlabEngine provides the close() method to implement thejavalangAutoCloseable interface for MatlabEngine objects This close()method enables you to use a try-with-resources statement to automatically disconnect orterminate the MATLAB session at the end of the statement
The MatlabEngine close() method disconnects or terminates the current MATLABsession depending on the context
bull If a Java process starts the MATLAB session as a default non-shared sessionclose() terminates MATLAB
bull If the MATLAB session is a shared session close() disconnects MATLAB from thisJava process MATLAB terminates when there are no other connections
To force the shutdown or disconnection of the current MATLAB session explicitly callMatlabEnginequit() MatlabEnginedisconnect() or their asynchronouscounterparts
engineclose()
ldquoClose MATLAB Engine Sessionrdquo
1 API Reference
1-190
Examples
Evaluate Function Asynchronously
This example shows how to evaluate a MATLAB function asynchronously The workflowis
bull Open a MATLAB sessionbull Invoke the MATLAB sqrt function with arguments asynchronouslybull Get the result of the MATLAB functionbull Close the MATLAB engine
import commathworksengineMatlabEngine
FutureltMatlabEnginegt engFuture = MatlabEnginestartMatlabAsync()MatlabEngine engine = engFutureget()double myVar = 4FutureltDoublegt future = enginefevalAsync(sqrt myVar)double result = futureget()Systemoutprintln(result)
See AlsomatlabengineengineName | matlabengineisEngineShared |matlabengineshareEngine
TopicsldquoBuild Java Engine ProgramsrdquoldquoStart and Close MATLAB Session from Javardquo
Introduced in R2016b
commathworksengineMatlabEngine class
1-191
commathworksmatlabtypesComplex classPackage commathworksmatlabtypes
Java class to pass complex data to and from MATLAB
DescriptionThe Complex class provides Java support for MATLAB complex arrays Use this class topass complex data to MATLAB The MATLAB engine passes complex data to Java as aninstance of Complex
All MATLAB numeric types are converted to double in Java
Constructor SummaryComplex(double real double imag) constructs an instance of Complex with thespecified real and imaginary values
Field Summarydouble real The real part of the complex datadouble imag The imaginary part of the complex data
Examples
Pass Complex Variable to MATLAB Function
import commathworksengineMatlabEngine
MatlabEngine engine = MatlabEnginestartMatlab()
1 API Reference
1-192
Complex c = new Complex(23)Complex cj = enginefeval(conjc)
bull ldquoUsing Complex Variables in Javardquo
See AlsocommathworksmatlabtypesCellStr |commathworksmatlabtypesHandleObject |commathworksmatlabtypesStruct
TopicsldquoUsing Complex Variables in Javardquo
Introduced in R2016b
commathworksmatlabtypesComplex class
1-193
commathworksmatlabtypesHandleObject classPackage commathworksmatlabtypes
Java class to represent MATLAB handle objects
DescriptionJava represents handle objects that are passed from MATLAB as instances of theHandleObject class When passing a handle object back to MATLAB Java passes areference to the HandleObject instance This reference can be either an array or ascalar depending on the original handle object passed to Java from MATLAB
You can pass a handle object only to the MATLAB session in which it was originallycreated You cannot construct a HandleObject in Java
Examples
Get Handle Object from MATLAB
This example starts a shared MATLAB session and creates a containersMap object inthe MATLAB workspace The statement evaluated in the MATLAB workspace returns ahandle variable that refers to the Map object
The engine getVariable function returns the MATLAB handle variable as aHandleObject instance This instance is used to call the MATLABcontainersMapkeys function to obtain the Map keys
import commathworksengineMatlabEngineimport commathworksmatlabtypes
MatlabEngine engine = MatlabEnginestartMatlab()engineeval(cm = containersMap(idname11mw))
1 API Reference
1-194
HandleObject handle = enginegetVariable(cm)String[] cells = enginefeval(keys handle)
See AlsocommathworksmatlabtypesCellStr |commathworksmatlabtypesComplex | commathworksmatlabtypesStruct
TopicsldquoUsing MATLAB Handle Objects in Javardquo
Introduced in R2016b
commathworksmatlabtypesHandleObject class
1-195
commathworksmatlabtypesStruct classPackage commathworksmatlabtypes
Java class to pass MATLAB struct to and from MATLAB
DescriptionThe Struct class provides support for passing data between MATLAB and Java as aMATLAB struct The Struct class implements the javautilMap interface
The Struct class is designed as an immutable type Attempting to change the mappingskeys or values of the returned Struct causes an UnsupportedOperationExceptionCalling these methods can cause the exception put() putAll() remove()entrySet() keySet() and values()
For an example see ldquoUsing MATLAB Structures in Javardquo
Constructor SummaryStruct s = new Struct(field1value1field2value2 ) creates aninstance of Struct with the specified field names and values
Method SummarycontainsKey(Object key) Returns true if this map contains a
mapping for the specified keycontainsValue(Object value) Returns true if this map maps one or more
keys to the specified valueentrySet() Returns a Set view of the mappings
contained in this mapequals(Object o) Compares the specified object with this
map for equality
1 API Reference
1-196
get(Object key) Returns the value to which the specifiedkey is mapped or null if this map containsno mapping for the key
hashCode() Returns the hash code value for this mapisEmpty() Returns true if this map contains no key-
value mappingskeySet() Returns a Set view of the keys contained
in this mapsize() Returns the number of key-value mappings
in this mapvalues() Returns a Collection view of the values
contained in this map
Examples
Create Struct for MATLAB Function Argument
Create a Struct and assign a key and value
import commathworksengineimport commathworksmatlabtypes
class StructProperties public static void main(String[] args) throws Exception MatlabEngine eng = MatlabEnginestartMatlab() int[] y = 12345 double[] color = 100507 Struct s = new Struct(ColorcolorLineWidth2) engfeval(plotys)
bull ldquoUsing MATLAB Structures in Javardquo
commathworksmatlabtypesStruct class
1-197
See AlsocommathworksmatlabtypesCellStr |commathworksmatlabtypesComplex |commathworksmatlabtypesHandleObject
TopicsldquoUsing MATLAB Structures in Javardquo
Introduced in R2016b
1 API Reference
1-198
commathworksmatlabtypesCellStr classPackage commathworksmatlabtypes
Java class to represent MATLAB cell array of char vectors
DescriptionThe CellStr class provides support for passing data from Java to MATLAB as aMATLAB cell array of char vectors (called a cellstr in MATLAB see cellstr) Thereare MATLAB functions that require cell arrays of char vectors as inputs To passarguments from Java to a MATLAB function requiring cellst inputs use the JavaCellStr class to create a compatible type
A MATLAB cellstr is mapped to a Java String array
Constructor SummaryCellStr(Object stringArray) creates a CellStr using a String or String arrayThe String array can have multiple dimensions
Method SummaryObject getStringArray() Get the String or String array used to
create the CellStrboolean equals(CellStr1CellStr2) Compare one CellStr instance with
another Two CellStr instances are equalif the String or String array they containare the same
commathworksmatlabtypesCellStr class
1-199
Examples
Construct CellStrThis example constructs a CellStr named keySet and puts the variable in theMATLAB base workspaceimport commathworksengineimport commathworksmatlabtypes
class javaCellstr public static void main(String[] args) throws Exception MatlabEngine eng = MatlabEnginestartMatlab() CellStr keySet = new CellStr(new String[]JanFebMarApr) engputVariable(mapKeyskeySet) engclose()
Construct CellStr Array
This example creates a CellStr array and passes it to the MATLAB plot function tochange the appearance of the graph produced by MATLAB The call to the MATLABprint function exports the figure as a jpeg file named myPlotjpg
import commathworksengineimport commathworksmatlabtypes
class CellStrArray public static void main(String[] args) throws Exception MatlabEngine eng = MatlabEnginestartMatlab() String[][] strArray = new String[2][2] strArray[0][0] = MarkerFaceColor strArray[0][1] = MarkerEdgeColor strArray[1][0] = green strArray[1][1] = red CellStr markerCellStr = new CellStr(strArray) engputVariable(MmarkerCellStr) engeval(plot(110--bsM)) engeval(print(myPlot-djpeg)) engclose()
1 API Reference
1-200
See AlsocommathworksmatlabtypesComplex |commathworksmatlabtypesHandleObject |commathworksmatlabtypesStruct
TopicsldquoPass Java CellStr to MATLABrdquo
Introduced in R2016b
commathworksmatlabtypesCellStr class
1-201
engClose (C and Fortran)Quit MATLAB engine session
C Syntaxinclude enginehint engClose(Engine ep)
Fortran Syntaxinclude enginehinteger4 engClose(ep)mwPointer ep
Argumentsep
Engine pointer
Returns0 on success and 1 otherwise Possible failure includes attempting to terminate analready-terminated MATLAB engine session
DescriptionThis routine sends a quit command to the MATLAB engine session and closes theconnection
1 API Reference
1-202
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc for a C example on UNIXreg operating systemsbull engwindemoc for a C example on Microsoftreg Windowsreg operating systemsbull fengdemoF for a Fortran example
See AlsoengOpen
Introduced before R2006a
engClose (C and Fortran)
1-203
engEvalString (C and Fortran)Evaluate expression in string
C Syntaxinclude enginehint engEvalString(Engine ep const char string)
Fortran Syntaxinclude enginehinteger4 engEvalString(ep string)mwPointer epcharacter() string
Argumentsep
Engine pointerstring
String to execute
Returns1 if the engine session is no longer running or the engine pointer is invalid or NULLOtherwise returns 0 even if the MATLAB engine session cannot evaluate the command
DescriptionengEvalString evaluates the expression contained in string for the MATLAB enginesession ep previously started by engOpen
1 API Reference
1-204
UNIX Operating Systems
On UNIX systems engEvalString sends commands to the MATLAB workspace bywriting down a pipe connected to the MATLAB stdin process MATLAB reads back fromstdout any output resulting from the command that ordinarily appears on the screeninto the buffer defined by engOutputBuffer
To turn off output buffering in C use
engOutputBuffer(ep NULL 0)
To turn off output buffering in Fortran use
engOutputBuffer(ep )
Microsoft Windows Operating Systems
On a Windows system engEvalString communicates with MATLAB software using aComponent Object Model (COM) interface
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc for a C example on UNIX operating systemsbull engwindemoc for a C example on Microsoft Windows operating systemsbull fengdemoF for a Fortran example
See AlsoengOpen engOutputBuffer
Introduced before R2006a
engEvalString (C and Fortran)
1-205
engGetVariable (C and Fortran)Copy variable from MATLAB engine workspace
C Syntaxinclude enginehmxArray engGetVariable(Engine ep const char name)
Fortran Syntaxinclude enginehmwPointer engGetVariable(ep name)mwPointer epcharacter() name
Argumentsep
Engine pointername
Name of mxArray to get from MATLAB workspace
ReturnsPointer to a newly allocated mxArray structure or NULL if the attempt failsengGetVariable fails if the named variable does not exist
DescriptionengGetVariable reads the named mxArray from the MATLAB engine sessionassociated with ep
1 API Reference
1-206
The limit for the size of data transferred is 2 GB
Use mxDestroyArray to destroy the mxArray created by this routine when you arefinished with it
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc for a C example on UNIX operating systemsbull engwindemoc for a C example on Microsoft Windows operating systems
See AlsoengPutVariable mxDestroyArray
Introduced before R2006a
engGetVariable (C and Fortran)
1-207
engGetVisible (C)Determine visibility of MATLAB engine session
C Syntaxinclude enginehint engGetVisible(Engine ep bool value)
Argumentsep
Engine pointervalue
Pointer to value returned from engGetVisible
Returns
Microsoft Windows Operating Systems Only
0 on success and 1 otherwise
DescriptionengGetVisible returns the current visibility setting for MATLAB engine session ep Avisible engine session runs in a window on the Windows desktop thus making the engineavailable for user interaction MATLAB removes an invisible session from the desktop
ExamplesThe following code opens engine session ep and disables its visibility
1 API Reference
1-208
Engine epbool vis
ep = engOpen(NULL)engSetVisible(ep 0)
To determine the current visibility setting use
engGetVisible(ep ampvis)
See AlsoengSetVisible
engGetVisible (C)
1-209
Engine (C)Type for MATLAB engine
DescriptionA handle to a MATLAB engine object
Engine is a C language opaque type
You can call MATLAB software as a computational engine by writing C and Fortranprograms that use the MATLAB engine library Engine is the link between yourprogram and the separate MATLAB engine process
The header file containing this type is
include engineh
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc shows how to call the MATLAB engine functions from a C programbull engwindemoc show how to call the MATLAB engine functions from a C program for
Windows systemsbull fengdemoF shows how to call the MATLAB engine functions from a Fortran
program
See AlsoengOpen
1 API Reference
1-210
engOpen (C and Fortran)Start MATLAB engine session
C Syntaxinclude enginehEngine engOpen(const char startcmd)
Fortran Syntaxinclude enginehmwPointer engOpen(startcmd)character() startcmd
Argumentsstartcmd
String to start the MATLAB process On Windows systems the startcmd stringmust be NULL
ReturnsPointer to an engine handle or NULL if the open fails
DescriptionThis routine allows you to start a MATLAB process for using MATLAB as acomputational engine
engOpen starts a MATLAB process using the command specified in the stringstartcmd establishes a connection and returns an engine pointer
engOpen (C and Fortran)
1-211
On UNIX systems if startcmd is NULL or the empty string engOpen starts a MATLABprocess on the current host using the command matlab If startcmd is a hostnameengOpen starts a MATLAB process on the designated host by embedding the specifiedhostname string into the larger string
rsh hostname bincsh -c setenv DISPLAY hostname0 matlab
If startcmd is any other string (has white space in it or nonalphanumeric characters)MATLAB executes the string literally
On UNIX systems engOpen performs the following steps
1 Creates two pipes2 Forks a new process Sets up the pipes to pass stdin and stdout from MATLAB
(parent) software to two file descriptors in the engine program (child)3 Executes a command to run MATLAB software (rsh for remote execution)
On Windows systems engOpen opens a COM channel to MATLAB The MATLABsoftware you registered during installation starts If you did not register duringinstallation enter the following command at the MATLAB prompt
matlab -regserver
See ldquoMATLAB COM Integrationrdquo for additional details
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc for a C example on UNIX operating systemsbull engwindemoc for a C example on Microsoft Windows operating systemsbull fengdemoF for a Fortran example
Introduced before R2006a
1 API Reference
1-212
engOpenSingleUse (C)Start MATLAB engine session for single nonshared use
C Syntaxinclude enginehEngine engOpenSingleUse(const char startcmd void dcom int retstatus)
Argumentsstartcmd
String to start MATLAB process On Microsoft Windows systems the startcmdstring must be NULL
dcomReserved for future use must be NULL
retstatusReturn status possible cause of failure
Returns
Microsoft Windows Operating Systems Only
Pointer to an engine handle or NULL if the open fails
UNIX Operating Systems
Not supported on UNIX systems
engOpenSingleUse (C)
1-213
DescriptionThis routine allows you to start multiple MATLAB processes using MATLAB as acomputational engine
engOpenSingleUse starts a MATLAB process establishes a connection and returns aunique engine identifier or NULL if the open fails Each call to engOpenSingleUsestarts a new MATLAB process
engOpenSingleUse opens a COM channel to MATLAB This starts the MATLABsoftware you registered during installation If you did not register during installationenter the following command at the MATLAB prompt
matlab -regserver
engOpenSingleUse allows single-use instances of an engine serverengOpenSingleUse differs from engOpen which allows multiple applications to use thesame engine server
See ldquoMATLAB COM Integrationrdquo for additional details
1 API Reference
1-214
engOutputBuffer (C and Fortran)Specify buffer for MATLAB output
C Syntaxinclude enginehint engOutputBuffer(Engine ep char p int n)
Fortran Syntaxinclude enginehinteger4 engOutputBuffer(ep p)mwPointer epcharactern p
Argumentsep
Engine pointerp
Pointer to character buffern
Length of buffer p
Returns1 if you pass it a NULL engine pointer Otherwise returns 0
engOutputBuffer (C and Fortran)
1-215
DescriptionengOutputBuffer defines a character buffer for engEvalString to return any outputthat ordinarily appears on the screen
The default behavior of engEvalString is to discard any standard output caused by thecommand it is executing A call to engOutputBuffer with a buffer of nonzero lengthtells any subsequent calls to engEvalString to save output in the character bufferpointed to by p
To turn off output buffering in C use
engOutputBuffer(ep NULL 0)
To turn off output buffering in Fortran use
engOutputBuffer(ep )
Note The buffer returned by engEvalString is not NULL terminated
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc for a C example on UNIX operating systemsbull engwindemoc for a C example on Microsoft Windows operating systemsbull fengdemoF for a Fortran example
See AlsoengOpen engEvalString
Introduced before R2006a
1 API Reference
1-216
engPutVariable (C and Fortran)Put variable into MATLAB engine workspace
C Syntaxinclude enginehint engPutVariable(Engine ep const char name const mxArray pm)
Fortran Syntaxinclude enginehinteger4 engPutVariable(ep name pm)mwPointer ep pmcharacter() name
Argumentsep
Engine pointername
Name of mxArray in the engine workspacepm
mxArray pointer
Returns0 if successful and 1 if an error occurs
DescriptionengPutVariable writes mxArray pm to the engine ep giving it the variable name name
engPutVariable (C and Fortran)
1-217
If the mxArray does not exist in the workspace the function creates it If an mxArraywith the same name exists in the workspace the function replaces the existing mxArraywith the new mxArray
The limit for the size of data transferred is 2 GB
Do not use MATLAB function names for variable names Common variable names thatconflict with function names include i j mode char size or path To determinewhether a particular name is associated with a MATLAB function use the whichfunction
The engine application owns the original mxArray and is responsible for freeing itsmemory Although the engPutVariable function sends a copy of the mxArray to theMATLAB workspace the engine application does not need to account for or free memoryfor the copy
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull engdemoc for a C example on UNIX operating systemsbull engwindemoc for a C example on Microsoft Windows operating systems
See AlsoengGetVariable
Introduced before R2006a
1 API Reference
1-218
engSetVisible (C)Show or hide MATLAB engine session
C Syntaxinclude enginehint engSetVisible(Engine ep bool value)
Argumentsep
Engine pointervalue
Value to set the Visible property to Set value to 1 to make the engine windowvisible or to 0 to make it invisible
Returns
Microsoft Windows Operating Systems Only
0 on success and 1 otherwise
DescriptionengSetVisible makes the window for the MATLAB engine session ep either visible orinvisible on the Windows desktop You can use this function to enable or disable userinteraction with the MATLAB engine session
engSetVisible (C)
1-219
ExamplesThe following code opens engine session ep and disables its visibility
Engine epbool vis
ep = engOpen(NULL)engSetVisible(ep 0)
To determine the current visibility setting use
engGetVisible(ep ampvis)
See AlsoengGetVisible
1 API Reference
1-220
matClose (C and Fortran)Close MAT-file
C Syntaxinclude mathint matClose(MATFile mfp)
Fortran Syntaxinclude mathinteger4 matClose(mfp)mwPointer mfp
Argumentsmfp
Pointer to MAT-file information
ReturnsEOF in C (-1 in Fortran) for a write error and 0 if successful
DescriptionmatClose closes the MAT-file associated with mfp
ExamplesSee the following examples in matlabrootexternexampleseng_mat
matClose (C and Fortran)
1-221
bull matcreatcbull matdgnscbull matdemo1Fbull matdemo2F
See AlsomatOpen
Introduced before R2006a
1 API Reference
1-222
matDeleteVariable (C and Fortran)Delete array from MAT-file
C Syntaxinclude mathint matDeleteVariable(MATFile mfp const char name)
Fortran Syntaxinclude mathinteger4 matDeleteVariable(mfp name)mwPointer mfpcharacter() name
Argumentsmfp
Pointer to MAT-file informationname
Name of mxArray to delete
Returns0 if successful and nonzero otherwise
DescriptionmatDeleteVariable deletes the named mxArray from the MAT-file pointed to by mfp
matDeleteVariable (C and Fortran)
1-223
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matdemo1F
Introduced before R2006a
1 API Reference
1-224
MATFile (C and Fortran)Type for MAT-file
DescriptionA handle to a MAT-file object A MAT-file is the data file format MATLAB software usesfor saving data to your disk
MATFile is a C language opaque type
The MAT-file interface library contains routines for reading and writing MAT-files Callthese routines from your own CC++ and Fortran programs using MATFile to accessyour data file
The header file containing this type is
include math
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matcreatcbull matdgnscbull matdemo1Fbull matdemo2F
See AlsomatOpen matClose matPutVariable matGetVariable mxDestroyArray
MATFile (C and Fortran)
1-225
matGetDir (C and Fortran)List of variables in MAT-file
C Syntaxinclude mathchar matGetDir(MATFile mfp int num)
Fortran Syntaxinclude mathmwPointer matGetDir(mfp num)mwPointer mfpinteger4 num
Argumentsmfp
Pointer to MAT-file informationnum
Pointer to the variable containing the number of mxArrays in the MAT-file
ReturnsPointer to an internal array containing pointers to the names of the mxArrays in theMAT-file pointed to by mfp In C each name is a NULL-terminated string The numoutput argument is the length of the internal array (number of mxArrays in the MAT-file) If num is zero mfp contains no arrays
matGetDir returns NULL in C (0 in Fortran) If matGetDir fails sets num to a negativenumber
1 API Reference
1-226
DescriptionThis routine provides you with a list of the names of the mxArrays contained within aMAT-file
matGetDir allocates memory for the internal array of strings using a mxCalloc Freethe memory using mxFree when you are finished with the array
MATLAB variable names can be up to length mxMAXNAM defined in the C header filematrixh
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matcreatcbull matdgnscbull matdemo2F
Introduced before R2006a
matGetDir (C and Fortran)
1-227
matGetFp (C)File pointer to MAT-file
C Syntaxinclude mathFILE matGetFp(MATFile mfp)
Argumentsmfp
Pointer to MAT-file information
ReturnsC file handle to the MAT-file with handle mfp Returns NULL if mfp is a handle to aMAT-file in HDF5-based format
DescriptionUse matGetFp to obtain a C file handle to a MAT-file Standard C library routines likeferror and feof use file handle to investigate errors
Introduced before R2006a
1 API Reference
1-228
matGetNextVariable (C and Fortran)Next array in MAT-file
C Syntaxinclude mathmxArray matGetNextVariable(MATFile mfp const char name)
Fortran Syntaxinclude mathmwPointer matGetNextVariable(mfp name)mwPointer mfpcharacter() name
Argumentsmfp
Pointer to MAT-file informationname
Pointer to the variable containing the mxArray name
ReturnsPointer to a newly allocated mxArray structure representing the next mxArray from theMAT-file pointed to by mfp The function returns the name of the mxArray in name
matGetNextVariable returns NULL in C (0 in Fortran) for end of file or if there is anerror condition In C use feof and ferror from the Standard C Library to determinestatus
matGetNextVariable (C and Fortran)
1-229
DescriptionmatGetNextVariable allows you to step sequentially through a MAT-file and readevery mxArray in a single pass The function reads and returns the next mxArray fromthe MAT-file pointed to by mfp
Use matGetNextVariable immediately after opening the MAT-file with matOpen andnot with other MAT-file routines Otherwise the concept of the next mxArray isundefined
Use mxDestroyArray to destroy the mxArray created by this routine when you arefinished with it
The order of variables returned from successive calls to matGetNextVariable is notguaranteed to be the same order in which the variables were written
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matdgnscbull matdemo2F
See AlsomatGetNextVariableInfo matGetVariable mxDestroyArray
Introduced before R2006a
1 API Reference
1-230
matGetNextVariableInfo (C and Fortran)Array header information only
C Syntaxinclude mathmxArray matGetNextVariableInfo(MATFile mfp const char name)
Fortran Syntaxinclude mathmwPointer matGetNextVariableInfo(mfp name)mwPointer mfpcharacter() name
Argumentsmfp
Pointer to MAT-file informationname
Pointer to the variable containing the mxArray name
ReturnsPointer to a newly allocated mxArray structure representing header information for thenext mxArray from the MAT-file pointed to by mfp The function returns the name of themxArray in name
matGetNextVariableInfo returns NULL in C (0 in Fortran) when the end of file isreached or if there is an error condition In C use feof and ferror from the Standard CLibrary to determine status
matGetNextVariableInfo (C and Fortran)
1-231
DescriptionmatGetNextVariableInfo loads only the array header information includingeverything except pr pi ir and jc from the current file offset
If pr pi ir and jc are nonzero values when loaded with matGetVariablematGetNextVariableInfo sets them to -1 instead These headers are forinformational use only Never pass this data back to the MATLAB workspace or save it toMAT-files
Use mxDestroyArray to destroy the mxArray created by this routine when you arefinished with it
The order of variables returned from successive calls to matGetNextVariableInfo isnot guaranteed to be the same order in which the variables were written
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matdgnscbull matdemo2F
See AlsomatGetNextVariable matGetVariableInfo
Introduced before R2006a
1 API Reference
1-232
matGetVariable (C and Fortran)Array from MAT-file
C Syntaxinclude mathmxArray matGetVariable(MATFile mfp const char name)
Fortran Syntaxinclude mathmwPointer matGetVariable(mfp name)mwPointer mfpcharacter() name
Argumentsmfp
Pointer to MAT-file informationname
Name of mxArray to get from MAT-file
ReturnsPointer to a newly allocated mxArray structure representing the mxArray named byname from the MAT-file pointed to by mfp
matGetVariable returns NULL in C (0 in Fortran) if the attempt to return the mxArraynamed by name fails
matGetVariable (C and Fortran)
1-233
DescriptionThis routine allows you to copy an mxArray out of a MAT-file
Use mxDestroyArray to destroy the mxArray created by this routine when you arefinished with it
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matcreatcbull matdemo1F
See AlsomatPutVariable mxDestroyArray
Introduced before R2006a
1 API Reference
1-234
matGetVariableInfo (C and Fortran)Array header information only
C Syntaxinclude mathmxArray matGetVariableInfo(MATFile mfp const char name)
Fortran Syntaxinclude mathmwPointer matGetVariableInfo(mfp name)mwPointer mfpcharacter() name
Argumentsmfp
Pointer to MAT-file informationname
Name of mxArray to get from MAT-file
ReturnsPointer to a newly allocated mxArray structure representing header information for themxArray named by name from the MAT-file pointed to by mfp
matGetVariableInfo returns NULL in C (0 in Fortran) if the attempt to return headerinformation for the mxArray named by name fails
matGetVariableInfo (C and Fortran)
1-235
DescriptionmatGetVariableInfo loads only the array header information including everythingexcept pr pi ir and jc It recursively creates the cells and structures through theirleaf elements but does not include pr pi ir and jc
If pr pi ir and jc are nonzero values when loaded with matGetVariablematGetVariableInfo sets them to -1 instead These headers are for informational useonly Never pass this data back to the MATLAB workspace or save it to MAT-files
Use mxDestroyArray to destroy the mxArray created by this routine when you arefinished with it
ExamplesSee the following examples in matlabrootexternexampleseng_mat
bull matdemo2F
See AlsomatGetVariable
Introduced before R2006a
1 API Reference
1-236
matlabengineconnect_matlabConnect shared MATLAB session to MATLAB Engine for Python
Syntaxeng = matlabengineconnect_matlab(name=None)eng = matlabengineconnect_matlab( ___ async)
Descriptioneng = matlabengineconnect_matlab(name=None) connects to the sharedMATLAB session name and returns a MatlabEngine object as eng The inputargument name specifies the name of a MATLAB session that is already running on yourlocal machine
bull If you specify name and the engine cannot find a shared MATLAB session of the samename then you receive an EngineError exception
bull If you do not specify name and the engine cannot find any shared MATLAB sessionsthen it starts a new shared MATLAB session If there are shared MATLAB sessionsrunning the engine connects to the first available session
bull If you do not specify name and the engine finds multiple shared MATLAB sessionsrunning then it connects to the first available session
eng = matlabengineconnect_matlab( ___ async) connects asynchronously ifasync is True
Examples
Connect to MATLAB Session
Connect to a shared MATLAB session that is already running on your local machine
matlabengineconnect_matlab
1-237
import matlabengineeng = matlabengineconnect_matlab()engsqrt(40)
20
matlabengineconnect_matlab connects to the first available shared MATLABsession If no MATLAB sessions are shared matlabengineconnect_matlab starts anew session
Connect to MATLAB Sessions by Name
When there are multiple shared MATLAB sessions on your local machine connect to twodifferent sessions one at a time by specifying their names
Connect to the first shared MATLAB session
import matlabenginenames = matlabenginefind_matlab()names
(MATLAB_6830 MATLAB_7090)
Connect to the second shared MATLAB session
eng = matlabengineconnect_matlab(MATLAB_7090)engsqrt(40)
20
bull ldquoConnect Python to Running MATLAB Sessionrdquo
Input Argumentsname mdash Name of shared MATLAB sessioncharacter array
Name of the shared MATLAB session specified as a character array
async mdash Start MATLAB synchronously or asynchronouslyFalse (default) | logical
1 API Reference
1-238
Start MATLAB synchronously or asynchronously specified as a logical keywordargumentExample matlabenginestart_matlab(async=True)
Output Argumentseng mdash Pythonreg variable for communicating with MATLABMatlabEngine object
Python variable for communicating with MATLAB returned as a MatlabEngine objecteng communicates with a shared MATLAB session that is already running on your localmachine
Limitationsbull Do not connect the engine multiple times to the same shared MATLAB session
See AlsomatlabengineMatlabEngine | matlabenginefind_matlab
TopicsldquoConnect Python to Running MATLAB Sessionrdquo
Introduced in R2015b
matlabengineconnect_matlab
1-239
matlabenginefind_matlabFind shared MATLAB sessions to connect to MATLAB Engine for Python
Syntaxnames = matlabenginefind_matlab()
Descriptionnames = matlabenginefind_matlab() finds all shared MATLAB sessions on yourlocal machine and returns their names in a tuple Any name in names can be the inputargument to matlabengineconnect_matlab If there are no shared sessionsrunning on your local machine matlabenginefind_matlab returns an emptytuple
Examples
Find Shared MATLAB Sessions
Identify the shared MATLAB sessions running on your local machine and connect to oneof them
import matlabenginenames = matlabenginefind_matlab()names
(MATLAB_6830 MATLAB_7090)
There are two shared MATLAB sessions running so matlabenginefind_matlabreturns two names in a tuple
Connect to the first shared MATLAB session
1 API Reference
1-240
eng = matlabengineconnect_matlab(MATLAB_6830)
bull ldquoConnect Python to Running MATLAB Sessionrdquo
See Alsomatlabengineconnect_matlab
TopicsldquoConnect Python to Running MATLAB Sessionrdquo
Introduced in R2015b
matlabenginefind_matlab
1-241
matlabengineFutureResult classPackage matlabengine
Results of asynchronous call to MATLAB function stored in Python object
DescriptionThe FutureResult class stores results of an asynchronous call to a MATLAB function ina Python object
ConstructionThe MATLAB Engine for Python creates a FutureResult object when a MATLABfunction is called asynchronously There is no need to callmatlabengineFutureResult() to create FutureResult objects of your own
Methods
cancel Cancel asynchronous call to MATLAB function from Pythoncancelled Cancellation status of asynchronous call to MATLAB function from Pythondone Completion status of asynchronous call to MATLAB function from Pythonresult Result of asynchronous call to MATLAB function from Python
ExceptionsSyntaxError Python exception syntax error in function
callTypeError Python exception data type of output
argument not supported
1 API Reference
1-242
matlabengineCancelledError MATLAB engine cannot cancel functioncall
matlabengineInterruptedError Function call interruptedmatlabengineMatlabExecutionError
Function call fails to execute
matlabengineRejectedExecutionError
Engine terminated
matlabengineTimeoutError Result cannot be returned within thetimeout period
Examples
Get Result of Asynchronous MATLAB Call from Python
Call the MATLAB sqrt function from Python Set async to True to make the functioncall asynchronously
import matlabengineeng = matlabenginestart_matlab()future = engsqrt(40async=True)ret = futureresult()print(ret)
20
bull ldquoCall MATLAB Functions from Pythonrdquobull ldquoCall MATLAB Functions Asynchronously from Pythonrdquo
See AlsomatlabengineMatlabEngine
TopicsldquoCall MATLAB Functions from PythonrdquoldquoCall MATLAB Functions Asynchronously from Pythonrdquo
matlabengineFutureResult class
1-243
Introduced in R2014b
1 API Reference
1-244