How to plot time data at different intervals?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all
I have data as follows:
Date: (Column 1)
08:06:2012
08:06:2012
09:06:2012
10:06:2012
13:06:2012
Time:(Column 2)
13:56:52
13:59:32
14:08:27
03:05:48
03:11:34
var_1:(Column 3)
0.448584
0.445232
0.414100
0.236846
0.239984
I want to plot var_1 but as you can see, the date and time are not given at same intervals. If I create an array with all seconds for all days (so that they are equally spaced), then it would take a lot of space since I have 3 years of data.
Any suggestions on how to plot this without creating an equally spaced time intervals with blank values for missing data of var_1 in the data file? I still need to have the gaps of missing date/time data on my plots though. I tried using the timeseries code as below, but it doesn't work because it still requires my data to be equally spaced...
x = var_1;
ts1 = timeseries(x,1:6);
ts1.Name = 'Secondsly Count';
ts1.TimeInfo.Units = 'seconds';
ts1.TimeInfo.StartDate=Date(1,1);
ts1.TimeInfo.Format = 'mmm dd, yyyy HH:MM:SS';
ts1.Time=ts1.Time-ts1.Time(1);
plot(ts1)
Thank you.
1 comentario
Stephen23
el 17 de Sept. de 2014
Most plot commands in MATLAB don't need evenly spaced data... try it, and see what happens!
Respuestas (1)
Star Strider
el 17 de Sept. de 2014
If you want to plot them, the interval between the measurements should not be a problem. They don’t have to be equally-spaced. Combine the date and time, create date numbers from them with datenum, and plot. Use datetick to help with your x-axis tick labels.
2 comentarios
Ver también
Categorías
Más información sobre Annotations 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!