Calling Script from python

3 views (last 30 days)
Gabriel Robles
Gabriel Robles on 26 Jan 2017
Commented: Gabriel Robles on 27 Jan 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

Answers (1)

Bo Li
Bo Li on 27 Jan 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 Comments
Gabriel Robles
Gabriel Robles on 27 Jan 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 on 27 Jan 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?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!