Pass Data to Python

MATLAB Type to Python Type Mapping

When you pass MATLAB® data as arguments to Python®, MATLAB converts the data into types that best represent the data to the Python language.

MATLAB Input Argument Type —
Scalar Values Only

Resulting Python py. Type

double
single

float

Complex single
Complex double

complex

int8
uint8
int16
uint16
int32

int

uint32
int64
uint64

int
long (version 2.7 only)

NaN

float(nan)

Inf

float(inf)

string scalar
char vector

str

<missing> value in string

None

logical

bool

Structure

dict

Python object — py.type

type

function handle @py.module.function, to Python functions only

module.function

MATLAB Vector to Python Mapping

MATLAB Input Argument Type —
1-by-N Vector

Resulting Python Type

double

array.array('d')

single

array.array('f')

int8

array.array('b')

uint8

array.array('B')

int16

array.array('h')

uint16

array.array('H')

int32

array.array('i')

uint32

array.array('I')

int64 (Not supported for Python 2.7 on Windows®)

array.array('q')

uint64 (Not supported for Python 2.7 on Windows)

array.array('Q')

char array containing values greater than 127 (version 2.7 only)

unicode

char vector
string scalar

str

cell vector

tuple

Related Examples

More About

Was this topic helpful?