how can i plot Time and Date from cell class (workspace)?

8 Ansichten (letzte 30 Tage)
Hasbian Perdhana
Hasbian Perdhana am 5 Okt. 2017
Kommentiert: Peter Perkins am 13 Okt. 2017
I have an EEG Data from Muse. the data is in .csv In this case i want to plot magnitude over time. the magnitude is a number which have values to be plotted, but the time data(column) in excel is a cell class(workspace), which is String type. as example : '2017-09-16 15:44:14.803' is there any function I can use to plot date and time?

Antworten (1)

Cam Salzberger
Cam Salzberger am 5 Okt. 2017
Hello Hasbian,
It's pretty easy to convert cell arrays of character arrays into datetimes, and then plot from there. In the case of irregular datetime character arrays, you simply have to tell datetime how to interpret them with the 'InputFormat' parameter:
c = {'2017-09-16 15:44:14.803' ; '2017-09-16 15:45:15.804'};
dt = datetime(c, 'InputFormat', 'yyyy-MM-dd HH:mm:ss.SSS')
If you use readtable to pull the data in though, you may be able to do this all in one step. See the link for an example.
-Cam
  1 Kommentar
Peter Perkins
Peter Perkins am 13 Okt. 2017
And just to be clear, once you have a datetime vector and a numeric vector, you can just plot them:
plot(dt,x)
On the other hand, you might find it more useful to plot EEG data against elapsed time, so perhaps something like
et = dt - dt(1); % or whatever base time is appropriate
et.Format = 's';
plot(et, x)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by