Running MatLab in Python error

1 回表示 (過去 30 日間)
syntheso
syntheso 2019 年 11 月 28 日
コメント済み: syntheso 2019 年 12 月 1 日
I am trying to follow the advice here to execute a custom Matlab function in Python.
Running the following code in Python (Spyder):
import matlab.engine
eng = matlab.engine.start_matlab()
eng.addpath(r'/Users/username/Desktop/spiray_array_model/matlab',nargout=0)
gives me this error:
Warning: Name is nonexistent or not a directory
I can confirm that '/Users/username/Desktop/spiray_array_model/matlab' is indeed a directory.
Is this because I am running from an IDE (Spyder) ? Or am I missing something else?

回答 (1 件)

Jesus Sanchez
Jesus Sanchez 2019 年 11 月 28 日
Have you tried to delete that "r" that is just before your path?
  3 件のコメント
Jesus Sanchez
Jesus Sanchez 2019 年 11 月 30 日
Then the only reason that I can think of is that something is missing. Try to write the full path, including 'C: ...' or whichever directory your folder is into.
syntheso
syntheso 2019 年 12 月 1 日
I'm using Mac, so you don't need to do that. /Users/ is the standard top level you need to go to.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall MATLAB from Python についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by