Cannot read data from a table to create a graph

2 ビュー (過去 30 日間)
Artur Nuritdinov
Artur Nuritdinov 2019 年 7 月 21 日
コメント済み: Artur Nuritdinov 2019 年 7 月 21 日
Hey everyone!
I have a table with data from motor sensors, but I cannot create graphs based on the data. And I don't understand what is wrong) Could someone help me?
This is the code:
Table that I use:
Error:
error.png
  4 件のコメント
madhan ravi
madhan ravi 2019 年 7 月 21 日
upload your data and code
Artur Nuritdinov
Artur Nuritdinov 2019 年 7 月 21 日
Code and table

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

採用された回答

Guillaume
Guillaume 2019 年 7 月 21 日
The problem is that your timestamp column is text and matlab does not know how to use text as a plot variable.
I assume that the text is supposed to be a duration, if so:
sensorData.timestamp = duration(sensorData.timestamp, 'InputFormat', 'mm:ss.S') %Don't know if it's the correct format
for i = 1:4
subplot(2,2,i)
plot(sensorData.timestamp,sensorData{:,9+i})
xlabel('Time')
end
  2 件のコメント
Artur Nuritdinov
Artur Nuritdinov 2019 年 7 月 21 日
編集済み: Artur Nuritdinov 2019 年 7 月 21 日
Hm, it worked with 200 rows of data, but it doesn't work with 5000 rows of data. I tried hh:mm:ss.S and mm:ss.S. The problem is already in the first row of the table
Attached the bigger table (Motor1_1) and the smaller one (Motor11) to the message
Guillaume
Guillaume 2019 年 7 月 21 日
The two files have completely different time format. Motor1_1.csv should be read as datetime directly by readtable in any recent version of matlab, so wouldn't need any conversion.
Motor11.csv having an unconventional time encoding needs the conversion as I've shown.

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

その他の回答 (1 件)

Artur Nuritdinov
Artur Nuritdinov 2019 年 7 月 21 日
I have found the mistake. Below is the correct code
CORRECT CODE.png
  2 件のコメント
Guillaume
Guillaume 2019 年 7 月 21 日
Please don't post screenshots of the code. Paste the code as text.
It's a bit poor form to accept your own answer, particularly as you didn't identify the original problem. Reputation, which we only get when answers are accepted or voted on is the only reward we get for helping you.
Artur Nuritdinov
Artur Nuritdinov 2019 年 7 月 21 日
Guillaume, sorry, I didn't know it. This is the first time when I ask the question and, in general, use MATLAB Answers. Thanks for your help! Will keep it in mind next time

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

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by