Python engine for Matlab 2015b

2 Ansichten (letzte 30 Tage)
Etienne Mazel
Etienne Mazel am 7 Aug. 2017
Beantwortet: Sharath Chandran am 17 Aug. 2017
Hi there,
Trying to have pyhton discover runing Matlab shared session on local Windows desktop... I have a rather special setup where Matlab is actually running using a special user on my desktop. I think i needed to make sure that TMP and TEMP environment variables would point to the same value the Matlab process uses. Still the following does not yield anything but empty string:
import os
import matlab.engine
os.environ["TMP"]='C:\\...' #same path as given by getenv('TMP')
os.environ["TEMP"]='C:\\...' #same path as given by getenv('TEMP')
names=matlab.engine.find_matlab()
print('Matlab names:', names)
Outcome is: Matlab names: ()
despite...
>> matlab.engine.isEngineShared
ans =
1
>> matlab.engine.engineName
ans =
MATLAB_6248
>>
Help is welcome.
Thanks

Antworten (1)

Sharath Chandran
Sharath Chandran am 17 Aug. 2017
Hi Etienne,
'%TEMP%' is the current standard. On the other hand '%TMP%' dates back to time when only DOS existed.
Please find more info here .
I would suggest you to try following steps:
1. Please make sure that MATLAB engine is shared. To do this execute following command at MATLAB command line:
>> matlab.engine.shareEngine
2. Try running following script:
import os
import matlab.engine
#change made here
os.environ["TMP"]= os.environ["TEMP"];
#same path as given by getenv('TEMP')
os.environ["TEMP"]='C:\\...'
#To make sure that MATLAB engine is connected.
#Following should display '2.0'
eng = matlab.engine.connect_matlab()
print eng.sqrt(4.0)
print "\n"
print matlab.engine.find_matlab()
Hope this helps.
Please feel free to reach out if this issue still persists.

Kategorien

Mehr zu Call MATLAB from Python finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by