Main Content


Find shared MATLAB sessions to connect to MATLAB Engine for Python



names = matlab.engine.find_matlab() finds all shared MATLAB® sessions on your local machine and returns their names in a tuple. Any name in names can be the input argument to matlab.engine.connect_matlab. If there are no shared sessions running on your local machine, matlab.engine.find_matlab returns an empty tuple.


collapse all

Identify the shared MATLAB sessions running on your local machine and connect to one of them.

import matlab.engine
names = matlab.engine.find_matlab()
('MATLAB_6830', 'MATLAB_7090')

There are two shared MATLAB sessions running, so matlab.engine.find_matlab returns two names in a tuple.

Connect to the first shared MATLAB session.

eng = matlab.engine.connect_matlab('MATLAB_6830')
Introduced in R2015b