필터 지우기
필터 지우기

How to RUN Python Function in R2022a

조회 수: 4 (최근 30일)
Mohd Khairi Mohd Zambri
Mohd Khairi Mohd Zambri 2022년 4월 20일
답변: Harshit Gupta 2022년 4월 26일
Hi,
I have 2 different version of MATLAB R2021a and R2022a
I try to run a python function in matlab and the python function script are as follow:
def myfunc(x):
if x%2==0:
print("It is an even number")
else:
print('It is an odd number')
Then I try to call py.Hello.myfunc(6) in R2021a -- it work with the result print "It is an even number"
But in R2022a is says "Unable to resolve the name 'py.Hello.myfunc' ".
Can Someone help on this matter for R2022a

답변 (1개)

Harshit Gupta
Harshit Gupta 2022년 4월 26일
It is my understanding that you are getting the error “Unable to resolve the name py.myfunc” while trying to run a Python function in MATLAB R2022a.
MATLAB automatically loads Python when you type py. followed by a Python statement at the MATLAB command prompt. If MATLAB displays this message, a failure has occurred in the call to myfunc.
Unable to resolve the name py.myfunc
Please refer to the below documentation page to troubleshoot the failure:

카테고리

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