can i determine whether a matlab engine is already running

5 次查看(过去 30 天)
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.

回答(2 个)

Jeremy Rutman
Jeremy Rutman 2015-9-27
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 2015-9-28
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.

类别

Help CenterFile Exchange 中查找有关 Call MATLAB from Python 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by