フィルターのクリア

Matlab kernel do not update python functions

1 回表示 (過去 30 日間)
Jeniffer Viegas
Jeniffer Viegas 2020 年 7 月 21 日
回答済み: Gouri Chennuru 2020 年 8 月 14 日
Hello,
I'm using Python in Matlab and when I import librarys such as numpy or pandas the code doesnt run in Matlab.
This is my code in Python saved as test_matlab_python.py:
import numpy as np
def media(x,y,z,n):
a = x*np.ones((n))
b = y*np.ones((n))
c= z*np.ones((n))
med = a+b+c
return med
and when I call in Matlab:
mediana = py.test_matlab_python.media(5,3,8,10)
I got the error
Unable to resolve the name py.test_matlab_python.media.
But if I modify my python function to:
def media(x,y,z):
med = x+y+z
return med
Then runs fine in Matlab, so I guess the problem is importing librarys, someone knows what I'm doing wrong?

回答 (1 件)

Gouri Chennuru
Gouri Chennuru 2020 年 8 月 14 日
Hi Jeniffer,
You can call Python libraries from MATLAB by installing a supported version with reference to the implementation for Python. MATLAB supports versions 2.7, 3.6, and 3.7. The version you install depends on the libraries you are using.
You can check the python version and change the default environment of Python interpreter by using "pyenv"
You can refer to these on how to call python from MATLAB.
Hope this helps!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by