Calling Matlab (2016a) function from Python(3.6)
rishika21sen at gmail.com
rishika21sen at gmail.com
Wed Mar 28 05:23:10 EDT 2018
So I am using the following code to call a Matlab(2016a) function from python(3.6).
>>import win32com.client
>>h = win32com.client.Dispatch('matlab.application')
>>h.Execute ("plot([0 18], [7 23])")
When I am using the 'Execute' statement to run a matlab file from python, I use the statement on python:
>>h.Execute ("run('H:\rishika\MATLAB\filewrite.m')")
Now this gives the error on python:
'??? Error: String is not terminated properly.\n\n'
On the other hand, when I am running the command:
>>run('H:\rishika\MATLAB\filewrite.m')
on command prompt of Matlab, it is working. But when run from python, the statement isn't executing.
But when I am executing
>>h.Execute ("disp('hi')")
on python, I am getting the proper output:
'hi\n'
Kindly point out my mistake.
P.S. I have tried installing matlab.engine, but I am having missing dll error, which I have not been able to resolve. Hence this method.
More information about the Python-list
mailing list