- Difficulty level: easy
- Time need to lean: 10 minutes or less
SoS tries to exchange variables with MATLAB/Octave in the most natural way. For example it converts numpy arrays to MATLAB matrix, and dictionaries to MATLAB struct. It converts Python DataFrame (or R data.frame
) to table
in MATLAB but to dataframe
in Octave because the latter is closer to Python DataFrame.
The convertion of datatype from SoS to MATLAB (Octave) is as followings:
Python | condition | MATLAB/Octave |
---|---|---|
None |
NaN |
|
boolean |
logical |
|
integer |
integer |
|
float |
float |
|
complex |
complex |
|
str |
str |
|
char |
char |
|
Sequence (list , tuple , ...) |
homogenous type, all numeric | vector |
Sequence (list , tuple , ...) |
homogenous type, all char | char |
Sequence (list , tuple , ...) |
multiple types | cell |
set |
cell |
|
dict |
struct |
|
numpy.ndarray |
cell |
|
numpy.matrix |
matrix |
|
pandas.DataFrame |
table (MATLAB) |
|
dataframe (Octave) |
Python objects in other datatypes are transferred as string "Unsupported datatype"
.
The convertion of datatype from MATLAB (Octave) to SoS is as followings:
MATLAB | length (n) | Python |
---|---|---|
NaN |
None |
|
logical |
1 |
boolean |
integer |
1 |
integer |
numeric |
1 |
double |
character |
1 |
string |
complex |
1 |
complex |
logical |
n > 1 |
list |
integer |
n > 1 |
list |
complex |
n > 1 |
list |
numeric |
n > 1 |
list |
character |
n > 1 |
list |
struct |
n > 0 |
numpy.ndarray |
matrix |
n > 0 |
numpy.array |
cell |
n > 0 |
numpy.ndarray |
table |
n > 0 |
pandas.DataFrame |
For example, a R dataframe is transfered as table to MATLAB.
InĀ [1]: