Import and plot .CSV with timestamp

10 次查看(过去 30 天)
I have a csv file along with timestamp and i cannot manage to plot my data correctly. My file is comma delimited, first date, then time and 3 different sensor values.. I can plot sensor values as datapoints but i need also the time.. Anyone eho can help?
  2 个评论
Guillaume
Guillaume 2018-11-7
An actual file instead of a picture of it would be a lot more useful for us to test.
i cannot manage to plot my data correctly. To tell what you did wrong we need to know what you did.

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2018-11-7
I'm not sure what you're doing wrong since you haven't shown us what you're doing. The following may be what you're after:
t = readtable('data3.csv');
t.datetime = t.(1) + t.(2); %merge date and time into one variable
plot(t.datetime, t{:, 3:5});
  15 个评论
Guillaume
Guillaume 2018-11-8
Well, most likely the error you actually received was Invalid Expression as I forgot a closing bracket. You must have added the bracket in the wrong place.
t.datetime = datetime(strcat(t{1, 1}, {' '}, t{1, 2})) + ... %timing of 1st sample
seconds(1/125) * (0:height(t)-1)'; %cumulatively add 1/125 second to timing of each sample
Or since you don't really care about the actual acquisition time of the samples, you could simply ignore the time information from the text file and do:
plot(seconds(1/125) * (0:height(t)-1), t{:, 3:5})
Ancalagon8
Ancalagon8 2018-11-8
It worked perfectly @Guillaume thank you for your time!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by