How to call matlab nested matlab functions from python?

1 回表示 (過去 30 日間)
Yusuf Khan
Yusuf Khan 2022 年 8 月 31 日
回答済み: Biral Pradhan 2022 年 9 月 5 日
Say my folder structure looks like this:
/project/
my_python_script.py
/some_cool_matlab_functions/
myfunction1.m
/some_different_cool_matlab_functions/
myfunction2.m
In my python script I run
import matlab.engine
engine = matlab.engine.start_matlab()
%#this next line fails
engine.some_cool_matlab_functions.myfunction1()
%#this also fails
engine.myfunction1()
How do I from python reference those functions that sit in subfolders? I can't seem to find actual documentation about matlab.engine beyond the examples on the mathworks site. I assume there must be a way to use the matlab.engine class or subclass to declare some kind of workspace etc.
Any help is appreciated.

回答 (1 件)

Biral Pradhan
Biral Pradhan 2022 年 9 月 5 日
Kindly check if the project folder is added to MATLAB path. For more information, kindly follow the below link.

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by