필터 지우기
필터 지우기

How to call python in Matlab?

조회 수: 1 (최근 30일)
Sheng Liu
Sheng Liu 2017년 12월 11일
답변: Khushboo 2022년 10월 27일
This is supposed to be simple because seems no one has this problem. I was told to run this code
py.numpy.zeros([3,3])
in Matlab. But it returns error: Undefined variable "py" or class "py.numpy.zeros".
I installed Python 3.5.3 it doesn't work. Then I tried Python 2.7, also doesn't work. Is there anything special I need to do. BTW, I am using Matlab 2017.
Thank you.

답변 (1개)

Khushboo
Khushboo 2022년 10월 27일
Hello,
I hope you have done the necessary setup for using Python in MATLAB and imported numpy in your MATLAB code using the following:
py.importlib.import_module('numpy')
More details regarding import can be found here.
Otherwise, it might be an issue with the setup. It would be better to install Python (Cpython) and make sure that numpy library is installed. Then you can launch MATLAB and make sure that MATLAB has loaded Python using the following:
pyversion
If this does not work, it would be really helpful if you could give more details regarding your environment (if you are using Anaconda) and path setup.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by