How to plot time data at different intervals?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2014-9-17
Most plot commands in MATLAB don't need evenly spaced data... try it, and see what happens!
回答(1 个)
Star Strider
2014-9-17
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!