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

Importing logical data from OML:

EvalOmlScript('opfalse = false;')
status = getomlvar('opfalse','pyfalse')
print(status)

1

Importing integer data from OML:

EvalOmlScript('opint = 999;')
status = getomlvar('opint','pyint')
print(status)

1

Importing precision data from OML:

EvalOmlScript('opfloat = 999.999;')
status = getomlvar('opfloat','pyfloat')
print(status)

1

Importing complex data from OML:

EvalOmlScript('opcomp= 99+99i;')
status = getomlvar('opcomp','pycomp')
print(status)

1

Importing string data from OML:

EvalOmlScript("opstring='String Data';")
status = getomlvar('opstring','pystring')
print(status)

1

Importing cell data from OML:

EvalOmlScript("opcell = {'aa','bb','cc','dd'};")
status = getomlvar('opcell','pylist')
print(status)

1

Importing struct data from OML:

EvalOmlScript("opstruct = struct('key1',123, 'key2','test');")
status = getomlvar('opstruct','pydict')
print(status)

1

Importing matrix data from OML:

EvalOmlScript("opmatrix = [1 2 -3;4 5 6;-7 8 0];")
status = getomlvar('opmatrix', 'pymatrix')
print(status)

1

Importing 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

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.