MatlabSession

class compas.com.MatlabSession(name=None)[source]

Bases: object

Communicate with Matlab through a shared session.

Parameters

name (str) – Name of a running Matlab session.

Notes

Note that the Matlab engine for Python is only available since R2014b. For earlier versions of Matlab, use MatlabProcess instead.

For more information, see 1

References

1

MathWorks, 2017. Connect Python to Running MATLAB Session. Available at https://ch.mathworks.com/help/matlab/matlab_external/connect-python-to-running-matlab-session.html

Examples

>>> m = MatlabSession()
>>> m.session_name
'MATLAB_13404'
>>> m.isprime(37)
True
# execute `matlab -nosplash -r "matlab.engine.shareEngine('MATLAB_xxx')"`
# to connect to an existing named session
>>> m = MatlabSession('MATLAB_xxx')
>>> m.isprime(37)
True

Methods

__init__([name])

x.__init__(…) initializes x; see help(type(x)) for signature

connect([name])

find_sessions()

init()