Timeseries using startdate - plot with events
显示 更早的评论
Hi, I have some difficulties displaying correctly timeseries with events in a plot with Matlab r2016b). In my case, I have a same startdate defined for my timeserie and all the events. When I plot the timeseries, the datatip for the second (and following) event displays the information of the first one.Hereafter is a simple example reproducing my issue:
test1 = timeseries();
test1.Time = [1 2 3 4 5];
test1.TimeInfo.Format= 'yyyy-mm-dd HH:MM:SS.FFF';
test1.TimeInfo.Units = 'seconds';
test1.TimeInfo.StartDate= '2018-01-01 00:00:00.000';
test1.Data = [2 1 4 1 4]';
event1 = tsdata.event('event1',2.0001);
event1.StartDate= '2018-01-01 00:00:00.000';
event2 = tsdata.event('event2', 3.45001);
event2.StartDate= '2018-01-01 00:00:00.000';
test1 = test1.addevent(event1);
test1 = test1.addevent(event2);
figure
subplot(1,1,1)
plot(test1)
What can I do to have a correct display of my events?
回答(1 个)
Adriano Bittar
2018-10-5
Try to use the following format to define the StartDate:
test1.TimeInfo.StartDate= datenum(2018,01,01,0,0,0);
event2.StartDate= datestr(datenum(2018,01,01,0,0,0)));
类别
在 帮助中心 和 File Exchange 中查找有关 Time Series Events 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!