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!