matlab.engine: PythonからMATLAB関数を呼び出す
matlab.engine
matlabengineforpython
install
Python 用の MATLAB エンジン API のインストール - MATLAB & Simulink - MathWorks 日本
$ cd $MATLAB_ROOT/extern/engines/python
$ pip install .
または
$ python setup.py install
error: could not create 'dist/matlabengine.egg-info': Permission denied
書き込み権限のない場所にmatlabがインストールされている場合に起こる
Matlab engine for python can not be installed if I don't have writing premissions - MATLAB Answers - MATLAB Central
やってみてはないyosider.icon
書き込み権限のある場所にMATLAB_ROOTをコピーしてくるといけた
例
$ MATLAB_ROOT=/usr/local/MATLAB/R2023b
$ cd ~/tmp
$ sudo cp -r $MATLAB_ROOT .
$ sudo chown -R user:user R2023b/
$ cd R2023b/extern/engines/python
$ pip install .
code:py
import matlab.engine
eng = matlab.engine.start_matlab()
tf = eng.isprime(37)
print(tf)
# True
t = eng.gcd(100.0,80.0,nargout=3)
print(t)
# (20.0, 1.0, -1.0)
Python からの MATLAB 関数の呼び出し - MATLAB & Simulink - MathWorks 日本
MATLAB から Python に返されたデータの処理 - MATLAB & Simulink - MathWorks 日本
Python 変数としての MATLAB 配列 - MATLAB & Simulink - MathWorks 日本