필터 지우기
필터 지우기

error in calling python function from matlab

조회 수: 1 (최근 30일)
puneet sharma
puneet sharma 2021년 11월 16일
댓글: Yongjian Feng 2021년 11월 20일
Hi all,
I am trying to run a python function which is in Raspberry pi from MATLAB but I am getting this error.
when I call the same function directly from Raspberry terminal I got the output. but from MATLAB i am getting this error.
ps - I called the python *script* in raspberry pi from MATLAB i got the result.
If anyone can tell me How I can call python *function* from MATLAB in raspberry pi.
please find the screenshot attached.
python function in raspberry --- def add(x,y):
return x+y

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 11월 20일
I am confused here. This doesn't look like valid python3 statements.
import /home/pi/Desktop/plus;
plus.add(150, 110)
Do you mean import home.pi.Desktop.plus; plus.add(150,110)?
  댓글 수: 2
Abhinav Prashar
Abhinav Prashar 2021년 11월 20일
so i am trying to run this file in python but through matlab thats why i have used system command ,but the issue is that its showing error with the function (add )defined in the python script (plus) in the raspi.In the python script i have defined the variable x,y and i am giving them value through matlab as describes in the pic .
Yongjian Feng
Yongjian Feng 2021년 11월 20일
Yes, from matlab system command actually runs the string input as a system command. As you can see from the second line of the error message, matlab tries to run the following from your command line:
sudo python3 -c "import /home/pi/Desktop/plus; plus.add(150, 110)"
Then the above doesn't look like a valid command line command. Python3 doesn't like the way you import the package.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by