Data Type Mappings Between C++ and Strongly Typed MATLAB Code - MATLAB & Simulink (original) (raw)
C++ to MATLAB
This table shows the mapping of C++ data types to strongly typed MATLABĀ® data types.
Description | C++ Data Type | MATLAB Data Type Representation |
---|---|---|
Real double scalar | double | (1,1) double {mustBeReal} |
Real double vector | std::vector | (1,:) double {mustBeReal} |
Complex double scalarCan be passed to MATLAB as plain real through C++ overloading | std::complex | (1,1) double |
Complex double vectorCan be passed to MATLAB as plain real through C++ overloading | std::vector<std::complex> | (1,:) double |
Real single scalar | float | (1,1) single {mustBeReal} |
Real single vector | std::vector | (1,:) single {mustBeReal} |
Complex single scalarCan be passed to MATLAB as plain real through C++ overloading | std::complex | (1,1) single |
Complex single vectorCan be passed to MATLAB as plain real through C++ overloading | std::vector<std::complex> | (1,:) single |
Real integer scalars | int8_tint16_tint32_tint64_t uint8_t uint16_tuint32_t uint64_t | (1,1) int8 {mustBeReal}(1,1) int16 {mustBeReal} (1,1) int32 {mustBeReal} (1,1) int64 {mustBeReal} (1,1) uint8 {mustBeReal}(1,1) uint16 {mustBeReal}(1,1) uint32 {mustBeReal} (1,1) uint64 {mustBeReal} |
Real integer vectors | std::vector<int8_t>std::vector<int16_t>std::vector<int32_t>std::vector<int64_t> std::vector<uint8_t>std::vector<uint16_t>std::vector<uint32_t> std::vector<uint64_t> | (1,:) int8 {mustBeReal}(1,:) int16 {mustBeReal} (1,:) int32 {mustBeReal} (1,:) int64 {mustBeReal} (1,:) uint8 {mustBeReal}(1,:) uint16 {mustBeReal}(1,:) uint32 {mustBeReal} (1,:) uint64 {mustBeReal} |
Complex integer scalars | std::complex<int8_t>std::complex<int16_t>std::complex<int32_t>std::complex<int64_t> std::complex<uint8_t>std::complex<uint16_t>std::complex<uint32_t> std::complex<uint64_t> | (1,1) int8(1,1) int16(1,1) int32(1,1) int64 (1,1) uint8 (1,1) uint16 (1,1) uint32 (1,1) uint64 |
Complex integer vectors | std::vector<std::complex<int8_t>>std::vector<std::complex<int16_t>>std::vector<std::complex<int32_t>>std::vector<std::complex<int64_t>> std::vector<std::complex<uint8_t>>std::vector<std::complex<uint16_t>>std::vector<std::complex<uint32_t>> std::vector<std::complex<uint64_t>> | (1,:) int8(1,:) int16(1,:) int32(1,:) int64 (1,:) uint8 (1,:) uint16 (1,:) uint32 (1,:) uint64 |
Logical scalar | bool | (1,1) logical |
Logical vector | std::vector | (1,:) logical |
Char scalar | char16_t | (1,1) char |
Char vector | std::u16string | (1,:) char |
String | std::u16string | (1,1) string |
String vector | std::vectorstd::u16string | (1,:) string |
Enum scalar | C++ scoped enumeration | (1,1) MyEnumClass |
Enum vector | std::vector of scoped enumeration | (1,:) MyEnumClass |
MATLAB to C++
This table shows the mapping of strongly typed MATLAB data types to C++ data types.
Description | MATLAB Data Type | C++ Data Type Representation |
---|---|---|
Real double scalar | (1,1) double {mustBeReal} | double orvector |
Real double vector | (1,:) double {mustBeReal} | std::vector |
Complex double scalarStored as a complex number, even if result is real | (1,1) double | std::complex |
Complex double vectorStored in MATLAB Data Array if result is real | (1,:) double | matlab::data::ArrayIf result contains DOUBLE orCOMPLEX_DOUBLE: matlab::data::ArrayType |
Real single scalar | (1,1) single {mustBeReal} | float |
Real single vector | (1,:) single {mustBeReal} | std::vector |
Complex single scalar | (1,1) single | std::complex |
Complex single vector | (1,:) single | matlab::data::ArrayIf result contains SINGLE orCOMPLEX_SINGLE: matlab::data::ArrayType |
Real integer scalars | (1,1) int8 {mustBeReal}(1,1) int16 {mustBeReal} (1,1) int32 {mustBeReal} (1,1) int64 {mustBeReal} (1,1) uint8 {mustBeReal}(1,1) uint16 {mustBeReal}(1,1) uint32 {mustBeReal} (1,1) uint64 {mustBeReal} | int8_tint16_tint32_tint64_t uint8_t uint16_tuint32_t uint64_t |
Real integer vectors | (1,:) int8 {mustBeReal}(1,:) int16 {mustBeReal} (1,:) int32 {mustBeReal} (1,:) int64 {mustBeReal} (1,:) uint8 {mustBeReal}(1,:) uint16 {mustBeReal}(1,:) uint32 {mustBeReal} (1,:) uint64 {mustBeReal} | std::vector<int8_t>std::vector<int16_t>std::vector<int32_t>std::vector<int64_t> std::vector<uint8_t>std::vector<uint16_t>std::vector<uint32_t> std::vector<uint64_t> |
Complex integer scalars | (1,1) int8(1,1) int16(1,1) int32(1,1) int64 (1,1) uint8 (1,1) uint16 (1,1) uint32 (1,1) uint64 | std::complex<int8_t>std::complex<int16_t>std::complex<int32_t>std::complex<int64_t> std::complex<uint8_t>std::complex<uint16_t>std::complex<uint32_t> std::complex<uint64_t> |
Complex integer vectors | (1,:) int8(1,:) int16(1,:) int32(1,:) int64 (1,:) uint8 (1,:) uint16 (1,:) uint32 (1,:) uint64 | matlab::data::ArrayIf result contains INT8, COMPLEX_INT8,INT16, COMPLEX_INT16,INT32, COMPLEX_INT32,INT64, COMPLEX_INT64,UINT8, COMPLEX_UINT8,UINT16, COMPLEX_UINT16,UINT32, COMPLEX_UINT32,UINT64, or COMPLEX_UINT64: matlab::data::ArrayType |
Logical scalar | (1,1) logical | bool |
Logical vector | (1,:) logical | std::vector |
Char scalar | (1,1) char | char16_t |
Char vector | (1,:) char | std::u16string |
String | (1,1) string | std::u16string |
String vector | (1,:) string | std::vectorstd::u16string |
Enum scalar | (1,1) MyEnumClass | scoped enumeration |
Enum vector | (1,:) MyEnumClass | std::vector of scoped enumeration |
MATLAB cell scalar | (1,1) cell | matlab::data::Array containing CELL matlab::data::ArrayType |
MATLAB cell vector | (1,:) cell | matlab::data::Array containing CELL matlab::data::ArrayType |
MATLAB struct | (1,1) struct | matlab::data::Array containingSTRUCT matlab::data::ArrayType |
MATLAB struct | (1,:) struct | matlab::data::Array containingSTRUCT matlab::data::ArrayType |
MATLAB type that is not a supported C++ type | matlab::data::Array |