exporttopython

Exports the OML variable value to the Python variable.

Syntax

[status,errorMessage]=exporttopython(omlVariable, PythonVariableName)

Inputs

PythonVariableName
PythonVariable name.
Type: string

Outputs

omlVariable
OMLVariable.
Type:
OMLVariable Type PythonVariable Type Limitations
Logical Bool  
Number Float  
Complex Complex  
String String  
Cell (m,n) List OML Cell(1,n) exported to Python list with N number of elements. OML Cell(m,n) exported to Python list with M number of elements and each element is a list with N number of elements. OML Cell(m,1) exported to Python list with M number of elements. OML Cell(m,0) exported to Python list with M number of elements and each element is an empty list. OML Cell(0,n) exported to Python empty list. Note: Python list resulted from exporting OML Cell(m,n) can be reshaped using OML function vertcat after importing it back to OML.
Struct dict Struct with one dimension only supported.
Matrix Numpy - matrix Data types supported in OML: matrix, Bool, Int, long, Float, Complex.
ND Matrix Numpy - Ndarray Data types supported in OML: matrix, Bool, Int, long, Float, Complex.
Sparse Matrix Scipy - CSC (Compressed Sparse Column Matrix)  

Examples

Exporting logical data to Python:
opfalse = false;
[status, errormessage] = exporttopython(opfalse,'opfalse')
status = 1
errormessage =
Exporting integer data to Python:
opint = 999;
[status, errormessage]=exporttopython(opint,'opint')
status = 1
errormessage =
Exporting precision data to Python:
opfloat = 999.999;
[status, errormessage] = exporttopython(opfloat,'opfloat')
status = 1
errormessage =
Exporting complex data to Python:
opcomp= 99+99i;
[status, errormessage]=exporttopython(opcomp,'opcomp')
status = 1
errormessage =
Exporting string data to Python:
postring='String Data'; 
[status, errormessage]=exporttopython(postring,'opstring')
status = 1
errormessage =
Exporting cell data to Python:
opcell_1_n = {'aa','bb','cc','dd'};
[status, errormessage] = exporttopython(opcell_1_n,'opcell_1_n')

opcell_0_n = cell(0,2);
[status, errormessage] = exporttopython(opcell_0_n,'opcell_0_n')


opcell_m_n = {'aa','bb','cc','dd';true,2,{1,2,3},ones(2)};
[status, errormessage] = exporttopython(opcell_m_n,'opcell_m_n')

opcell_m_0 = cell(2,0);
[status, errormessage] = exporttopython(opcell_m_0,'opcell_m_0')

opcell_m_1 = {'aa';'bb';'cc';'dd'};
[status, errormessage] = exporttopython(opcell_m_1,'opcell_m_1')
status = 1
errormessage = 
status = 1
errormessage = 
status = 1
errormessage = 
status = 1
errormessage = 
status = 1
errormessage = 
Exporting struct data to Python:
opstruct = struct('key1',123, 'key2','test');
[status, errormessage]=exporttopython(opstruct,'opstruct')
status = 1
errormessage =
Exporting matrix data to Python:
opmatrix = [1 2 -3;4 5 6;-7 8 0];
[status, errormessage ]= exporttopython(opmatrix,'opmatrix')
status = 1
errormessage =
Exporting nd matrix data to Python:
opndmatrix = [1,2,3;4,5,6];
opndmatrix(:,:,2) = [7,8,9;10,11,12];
[status, errormessage ] = exporttopython(opndmatrix,'opndmartix')
status = 1
errormessage =
Export Sparse matrix data to Python:
row = [1, 2, 4, 4, 1, 5, 2, 3, 4, 1, 2, 3, 4, 1, 4];
col = [1, 1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6];
vals = [10, 20, 40, -90, 110, 150, 170, 180, 190, 210, -220, 230, 240, 260, 290];
s = sparse(row, col, vals);
[status, errormessage ] = exporttopython(s,'s')
status = 1
errormessage =