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 件のコメント
Faustine Delhay
2018 年 1 月 8 日
回答 (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!