How to seperate serial data into separate columns

1 回表示 (過去 30 日間)
MATLABmet
MATLABmet 2017 年 8 月 28 日
コメント済み: MATLABmet 2017 年 8 月 28 日
HI all,
I am acquiring serial data from a three axis accelerometer (ADXL345) connected to an arduino. I can successfully read the serial data into matlab using using the 'fgets' function (after opening the com port etc). However, my data which is formatted as x,y,z, is coming in a single column for example -3,-21,28.
How would I go about separating this data into separate columns for further analysis.
Thanks in advance,
  2 件のコメント
Stephen23
Stephen23 2017 年 8 月 28 日
MATLABmet's "Answer" moved here:
Hi KSSV and KL,
thanks both for your answers,
I have attached my code, as i think my understanding isn't good enough to just implement suggestions.
Should i be storing my serial data (s) as a separate value ? As i've realised my for loop is just over writing the same value each time.
thanks again,
Stephen23
Stephen23 2017 年 8 月 28 日
@MATLABmet: answers are for answering the question. Comments are for commenting. Please use them.

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

採用された回答

KL
KL 2017 年 8 月 28 日
your_cell_array = {'21.0,12.232,43';'21.0,12.232,43';'21.0,12.232,43'}
new_cell_array = regexp(your_cell_array, ',', 'split')
  1 件のコメント
MATLABmet
MATLABmet 2017 年 8 月 28 日
Sorry for my previous misunderstanding. KL this worked for me once i got my head round it. thank you for your help!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by