Best method to handle time series HH:MM:SS.FFF
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
What is the best method to create a time vector for plots and for comparing data when knowing the start time in HH:MM:SS.FFF and the sampling rate? The constant sampling rate/interval is in microseconds, thus several samples would have the same HH:MM:SS.FFF if kept in that format with only three decimal places.
I want to be able to compare data from the same time periods (that may have different start times) for comparisson and plot them showing the HH:MM:SS.FFF on the x axis.
Thanks.
0 comentarios
Respuestas (1)
Star Strider
el 28 de Ag. de 2014
It’s difficult to answer your question because I can’t determine whether your priorities are to keep the time in HH:MM:SS.FFF format or to display all the samples.
One possibility is for you to keep all the original sampling times and simply label your time axis every millisecond. (That would be my approach.) This might require a visit to the realm of handle graphics to set the 'XTick' values to be only where you want them. You will likely need to use the datetick function to label your time axis in any event.
Another possibility is to average them over every millisecond and simply display them every millisecond. (That would not be my approach if I went through the trouble to sample them every microsecond.)
Plotting them with different start times would be relatively easy, since the plot function would take care of that automatically. I don’t see a need to actually label the start times on your time (probably x) axis though, unless that is an important parameter.
2 comentarios
Star Strider
el 28 de Ag. de 2014
The plot command will align them with respect to ‘absolute’ times even if they do not start at some arbitrary t=0.
Example:
x1 = linspace(0,2*pi,90);
x2 = linspace(pi/3,7*pi/3,110);
y1 = sin(x1);
y2 = cos(x2);
plot(x1,y1, x2,y2)
grid
They don’t even have to have the same sampling times or sampling intervals, so long as the associated x- and y-vectors have the same lengths.
The only problem is the conversion to datestr or datevec format. You would there be restricted to millisecond resolution. So long as you keep them as datenum serial numbers (parts of which you create), you can do pretty much anything within MATLAB’s floating-point precision.
Aligning them outside the plot, for instance to compare them somehow, would be a bit more challenging, depending on how you want to align them.
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!