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

 采纳的回答

Guillaume
Guillaume 2017-6-27
编辑:Guillaume 2017-6-27
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)

更多回答(1 个)

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

类别

在 帮助中心 和 File Exchange 中查找有关 App Building 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by