フィルターのクリア

How can I run a python function in raspberry pi from MATLAB shell command?

2 ビュー (過去 30 日間)
Sanchit Jain
Sanchit Jain 2021 年 11 月 14 日
回答済み: Harsh 2024 年 4 月 30 日
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 件)

Harsh
Harsh 2024 年 4 月 30 日
Hi Sanchit,
It seems like you're attempting to run a Python script on your Raspberry Pi using MATLAB's system command.
The error you're encountering is likely caused by incorrect syntax in the argument of “system” function. To resolve this issue, you can modify the parameters of the "system" command, used in line 3.
You can use the following modified “system” function call:
system(b, 'python3 -c "import os.path; import sys; sys.path.append(os.path.expanduser(''~/Desktop'')); import plus; plus.add(150, 110)"', 'sudo')
I hope this helps, thanks!

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Raspberry Pi Hardware についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by