Calling Script from python

3 visualizzazioni (ultimi 30 giorni)
Gabriel Robles
Gabriel Robles il 26 Gen 2017
Commentato: Gabriel Robles il 27 Gen 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

Risposte (1)

Bo Li
Bo Li il 27 Gen 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 Commenti
Gabriel Robles
Gabriel Robles il 27 Gen 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 il 27 Gen 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?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by