wrong time format in table
Afficher commentaires plus anciens
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
Plus de réponses (1)
Steven Lord
le 27 Juin 2017
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!