can i determine whether a matlab engine is already running

20 ビュー (過去 30 日間)
Jeremy Rutman
Jeremy Rutman 2015 年 9 月 27 日
回答済み: Bo Li 2015 年 9 月 28 日
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.

製品

Community Treasure Hunt

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

Start Hunting!

Translated by