Pass Data Between MATLAB Production Server and Python
R2026bPass Data from MATLAB to Python
When you pass data from MATLAB® to Python®, either directly or as output from a MATLAB function in Python, MATLAB converts the data into the equivalent Python data types.
MATLAB Output Argument Type | Resulting Python Data Type |
|---|---|
Numeric array |
|
|
|
Complex (any numeric type) |
|
|
|
|
|
|
|
|
|
|
|
|
|
string array (1-by-N or
N-by-1) |
|
|
|
cell array (1-by- |
|
|
|
|
|
|
|
|
|
|
|
tabletimetable |
|
MATLAB handle object (such as the
|
|
MATLAB value object (such as the |
|
Unsupported MATLAB Data Types
Along with the exceptions noted in the table, MATLAB does not convert these MATLAB data types to Python data types:
chararray (M-by-N)stringarray (M-by-N)cell array (
M-by-N)Sparse array
structarrayObjects not produced by MATLAB (such as Java® objects)
Function handle
Pass Data from Python to MATLAB
When you pass data from Python to MATLAB, either directly or as input arguments to a MATLAB function in Python, MATLAB Production Server™ converts the data into the equivalent MATLAB data types.
Python Data Type | Resulting MATLAB Data Type |
|---|---|
| Numeric array |
Python objects that support the buffer protocol, such as
|
Numeric array |
|
|
| Complex |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Python objects other than |
|
| When you pass a MATLAB object that does not have an explicit conversion rule to
Python, MATLAB passes it as a |
Unsupported Python Data Types
Along with the exceptions noted in the table, MATLAB does not convert these Python data types to MATLAB data types:
Python class (
module.type) objectsNoneobjectenumtype