Timeseries using startdate - plot with events
Show older comments
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 Comment
Faustine Delhay
on 8 Jan 2018
Answers (1)
Adriano Bittar
on 5 Oct 2018
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)));
Categories
Find more on Time Series Events in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!