フィルターのクリア

Processing data received via a COM port

1 回表示 (過去 30 日間)
Theodor Cîrmaciu
Theodor Cîrmaciu 2023 年 10 月 23 日
回答済み: Walter Roberson 2023 年 10 月 23 日
Hello, I have a microcontroller which outputs 3 values via a COM port. Each pair of values is spaced and separated by a new line from the others, for example:
10 11 21
92 23 12
34 44 22
etc.
How could I process this data in real time using the serialport function? I would like to continuously plot the x,y,z values in 3 subplots.
Thank you in advance!

採用された回答

Walter Roberson
Walter Roberson 2023 年 10 月 23 日
First create the serialport object. Then configureTerminator . Then configureCallback with "mode" "terminator" . The configured callback should readline to get the values, then parse the values and do something appropriate with them.
If you are sure that the values are numeric (and nothing but numeric) then you can parse the line using sscanf . Or you can potentially
double(strsplit(LINE))
This relies on the fact that readline() returns a string scalar not a character vector.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSerial and USB Communication についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by