Send data from Raspberry Pi to MATLAB?

4 ビュー (過去 30 日間)
Palash Thakur
Palash Thakur 2018 年 2 月 27 日
回答済み: Yingnan Huang 2020 年 9 月 21 日
I am tracking the position of an object on a Raspberry Pi 3 and am generating an array of object positions, which I want to send continuously to a MATLAB script running on my PC, which will plot the object's trajectory in x and y. What's the best way I can go about sending the position values to MATLAB?
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 2 月 27 日
Are you programming at the MATLAB level or at the Simulink level? At the Simulink level, there are TCP and UDP blocks for Raspberry Pi
Palash Thakur
Palash Thakur 2018 年 2 月 27 日
編集済み: Palash Thakur 2018 年 2 月 27 日
I am using MATLAB, actually. I wanted to take the position, run them through a control algorithm, and control two servos accordingly (all this as quickly as possible). Right now I just wanted to plot the data.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 2 月 27 日
Create a serial connection. Have the raspberry pi print the values on the serial port. Read from the serial port on the MATLAB side. https://www.mathworks.com/help/supportpkg/raspberrypiio/ref/raspi.serialdev.read.html
This assumes you have a serial or USB-over-serial connection.
Alternately, it is possible to write some C code for the Pi that sends information by TCP or UDP, which you could receive on the MATLAB end by using the Instrument Control Toolbox tcp() or udp() functions, or by grabbing the File Exchange contribution tcpudpip . I do not know how best to write the C code for TCP or UDP for the raspberry pi... I do not happen to have experience with the available libraries for raspberry pi.
  1 件のコメント
Palash Thakur
Palash Thakur 2018 年 2 月 27 日
Thank you. I'll look into this.

サインインしてコメントする。


Yingnan Huang
Yingnan Huang 2020 年 9 月 21 日
Dear, did you got any good solutions to this problem?

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by