Import and plot .CSV with timestamp

10 vues (au cours des 30 derniers jours)
Ancalagon8
Ancalagon8 le 7 Nov 2018
Commenté : Ancalagon8 le 8 Nov 2018
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 commentaires
Guillaume
Guillaume le 7 Nov 2018
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.
Ancalagon8
Ancalagon8 le 7 Nov 2018
@Guillaume

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
Guillaume le 7 Nov 2018
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 commentaires
Guillaume
Guillaume le 8 Nov 2018
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 le 8 Nov 2018
It worked perfectly @Guillaume thank you for your time!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by