Calling Script from python

3 次查看(过去 30 天)
Gabriel Robles
Gabriel Robles 2017-1-26
Hi, i've been trying to call an script from python using the engine but i can't do it, the following message pops up:<matlab.engine.matlabengine.MatlabFunc object at 0x02C409D0>. I would appreciate if you could help me

回答(1 个)

Bo Li
Bo Li 2017-1-27
I can reproduce your error message with following steps:
>>> import matlab.engine
>>> eng=matlab.engine.start_matlab("-nojvm")
>>> eng.sqrt
<matlab.engine.matlabengine.MatlabFunc object at 0x7f4efd26ded0>
If that is what you did, the simple fix is to provide arguments for the function call like this:
>>> eng.sqrt(4.)
2.0
  2 个评论
Gabriel Robles
Gabriel Robles 2017-1-27
I modified the script and finally i've fixed the error. This is my code:
import matlab.engine
eng=matlab.engine.start_matlab()
eng.cd(r'C:\Users\Alejandro\Desktop',nargout=0)
eng.run('Test',nargout=0)
I used the command 'run' in order to execute the script
Gabriel Robles
Gabriel Robles 2017-1-27
i would appreciate if you could answer to me another question. I want to run a Matlab script from python using the engine and at the same time this script will need variables defined in the python script, There is any way to do that?

请先登录,再进行评论。

类别

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