I have 100000x4 table with time|voltage|voltage|voltage and i need to plot the voltages vs time. Unfortunately the time column is in the format "d/M/y HH:mm:ss.SSSSSS" and do not start on an absolute zero. how can i extract or change the time from '2/6/2040 00:59:59.999984' in order to make a plot of it?
R2017a

 Réponse acceptée

Guillaume
Guillaume le 27 Juin 2017
Modifié(e) : Guillaume le 27 Juin 2017

0 votes

There is no absolute zero datetime, but you can certainly retime your time column to start at whichever arbitrary date you want:
yourtable.time = yourtable.time + (datetime(2040, 6, 2, 0, 59, 59.999984) - yourtable.time(1))
Although, are you sure about that 0.999984? Isn't it a rounded value for display?
Alternatively convert your datetimes to a duration (which has an absolute zero):
yourtable.time = yourtable.time - yourtable.time(1)

Plus de réponses (1)

Steven Lord
Steven Lord le 27 Juin 2017

0 votes

If you want to plot the data and have your times stored as a datetime array, just go ahead and plot it. The plot function knows how to handle datetime data.
v = 0:10;
t0 = datetime('today');
t = t0 + days(v);
plot(t, v.^2)
Or if you have t and v and want to plot using the first time in t as the "base time" representing 0:
h = plot(t - t(1), v.^2);
ax = ancestor(h, 'axes');
ax.XAxis.TickLabelFormat = 'd'; % Display the ticks as days not hh:mm:ss

Catégories

En savoir plus sur App Building dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by