Calling Script from python

조회 수: 3 (최근 30일)
Gabriel Robles
Gabriel Robles 2017년 1월 26일
댓글: Gabriel Robles 2017년 1월 27일
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