can i determine whether a matlab engine is already running

4 views (last 30 days)
I would like to avoid restarting the matlab engine every time I need a matlab calculation. Is there a way to determine whether an engine is already running? I currently start a new engine every time using
#python
eng = matlab.engine.start_matlab()
I have tried storing the eng object in a redis key-value store but the object reference seems to get converted to a string.

Answers (2)

Jeremy Rutman
Jeremy Rutman on 27 Sep 2015
ok it seems in 2015b there are 'shared engines' which can be shared using matlab.engine.shareEngine
now I would like to avoid having to open matlab directly so I want to run that matlab command ( matlab.engine.shareEngine) from an engine i start in python. Thus I start an engine normally (from python): eng = matlab.engine.start_matlab() and then try to share it using
eng.matlab.engine.shareEngine
but this causes an error. For some reason
eng.shareEngine
runs but does not seem to create a shared engine. Is there a way to do this?

Bo Li
Bo Li on 28 Sep 2015
What do you mean by "eng.shareEngine runs but does not seems to create a shared engine"?
Typically, you would launch a MATLAB and convert it into a shared session:
%MATLAB code
>>matlab.engine.shareEngine
After that, you can connect to this shared MATLAB from a Python session:
>>>engs=matlab.engine.find_matlab()
>>>eng=matlab.engine.connect_matlab(engs[0])
Not sure about the redis issue, but it should be applicable to other Python objects.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!