Calling Matlab (2016a) function from Python(3.6)

Michael Torrie torriem at gmail.com
Thu Mar 29 23:42:38 EDT 2018


On 03/28/2018 11:24 PM, Rishika Sen wrote:
> I tried these options too as suggested by Paul...
> 
>>>> h.Execute ("run('H:\\rishika\\MATLAB\\filewrite.m')")
> '??? Error using run (line 41)\nH:\\rishika\\MATLAB\\filewrite.m not found.\n\n'

Crazy question, but you're sure of that path?

>>>> h.Execute ("run(r'H:\rishika\MATLAB\filewrite.m')")
> '??? Error: Unexpected MATLAB expression.\n\n

Not surprised there. MATLAB doesn't know what to do with the extra r you
put in there. The r expression should be added to the python string, not
the bit inside.

h.Execute(r"run('H:\rishika\MATLAB\filewrite.m')")
         ^^^^

You might also try using forwards slashes for folder delimiters. All
windows APIs can deal with them.

h.Execute("run('H:/rishika/MATLAB/filewrite.m')")






More information about the Python-list mailing list