Calling Script from python

5 visualizaciones (últimos 30 días)
Gabriel Robles
Gabriel Robles el 26 de En. de 2017
Comentada: Gabriel Robles el 27 de En. de 2017
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

Respuestas (1)

Bo Li
Bo Li el 27 de En. de 2017
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 comentarios
Gabriel Robles
Gabriel Robles el 27 de En. de 2017
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 el 27 de En. de 2017
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?

Iniciar sesión para comentar.

Categorías

Más información sobre Call MATLAB from Python en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by