getomlvar

Imports the OML variable value to the Python variable

Syntax

status = getomlvar(OMLVariableName,PythonVariableName)

Inputs

OMLVariableName
OML variable name.
Type: string
PythonVariableName
Python variable name.
Type: string

Outputs

status
Status of the script executed.
1
success
“error message”
failure
Type: int | string

Examples

Import logical data from OML:
EvalOmlScript('opfalse = false;')
status = getomlvar('opfalse','pyfalse')
print(status)
1
Import integer data from OML:
EvalOmlScript('opint = 999;')
status = getomlvar('opint','pyint')
print(status)
1
Import precision data from OML:
EvalOmlScript('opfloat = 999.999;')
status = getomlvar('opfloat','pyfloat')
print(status)
1
Import complex data from OML:
EvalOmlScript('opcomp= 99+99i;')
status = getomlvar('opcomp','pycomp')
print(status)
1
Import string data from OML:
EvalOmlScript("opstring='String Data';")
status = getomlvar('opstring','pystring')
print(status)
1
Import cell data from OML:
EvalOmlScript("opcell = {'aa','bb','cc','dd'};")
status = getomlvar('opcell','pylist')
print(status)
1
Import struct data from OML:
EvalOmlScript("opstruct = struct('key1',123, 'key2','test');")
status = getomlvar('opstruct','pydict')
print(status)
1
Import matrix data from OML:
EvalOmlScript("opmatrix = [1 2 -3;4 5 6;-7 8 0];")
status = getomlvar('opmatrix', 'pymatrix')
print(status)
1
Import nd matrix data from OML:
EvalOmlScript("opndmatrix = [1,2,3;4,5,6];")
EvalOmlScript("opndmatrix(:,:,2) = [7,8,9;10,11,12];")
status = getomlvar('opndmatrix','pyndmatrix')
print(status)
1
Import Sparse matrix data from OML
EvalOmlScript("row = [1, 2, 4, 4, 1, 5, 2, 3, 4, 1, 2, 3, 4, 1, 4];")
EvalOmlScript("col = [1, 1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6];")
EvalOmlScript("vals = [10, 20, 40, -90, 110, 150, 170, 180, 190, 210, -220, 230, 240, 260, 290];")
EvalOmlScript("s = sparse(row, col, vals);")
status = getomlvar('s','s')
print(status)
1

Comments

Any error reported is returned as a string. Returns 1 on success.
Table 1. Data Type Mapping
OML Variable Type Python Variable Type Limitations
Logical Bool  
Number Float  
Complex Complex  
String String  
Cell (1,n) n:number of elements in list List Cell with one dimension only supported.
Struct dict Struct with one dimension only supported.
Matrix Numpy - Matrix Data types supported in OML include: matrix, Bool, Int, long, Float, Complex.
ND Matrix Numpy Ndarray Data types supported in OML include: matrix, Bool, Int, long, Float, Complex.
Sparse matrix Scipy - CSC (Compressed Sparse Column Matrix)