How can I specify time in milliseconds while specifying the time vector of a timeseries object?

조회 수: 39 (최근 30일)
When I execute the following code:
data=load('data.mat', '-ascii');
ctime={'13:28:24.293';'13:28:24.794' ;'13:28:25.294' ;'13:28:25.795' ;'13:28:26.298' ;'13:28:26.799' ;'13:28:27.308' ;'13:28:27.809' ;'13:28:28.309' ;'13:28:28.823' };
tsData = timeseries(data, ctime);
I receive the following error:
??? Error using ==> tsAnalyzeAbsTime at 49
Duplicate times are found.
Error in ==> timeseries.setabstime at 26
[thisTime,h.TimeInfo.Startdate] = ...
Error in ==> timeseries.init at 239
this = setabstime(this,time(I));
Error in ==> timeseries.timeseries>timeseries.timeseries at 257
this = init(this,varargin{:});

채택된 답변

MathWorks Support Team
MathWorks Support Team 2018년 10월 18일
The HH:MM:SS.FFFF time format is not a valid time vector format while creating time series objects. Refer to the following link for more information:
Instead of creating a timeseries object using serial date numbers created using datenum, convert your time strings to datetime and using the datetime data to create a timetable. datetime can handle dates to nanosecond precision.
For example:
ctime={'13:28:24.293';'13:28:24.794' ;'13:28:25.294' ;'13:28:25.795'; ...
'13:28:26.298';'13:28:26.799' ;'13:28:27.308' ;'13:28:27.809'; ...
'13:28:28.309';'13:28:28.823' };
fmt = 'HH:mm:ss.SSS';
dt = datetime(ctime, 'InputFormat', fmt, 'Format', fmt);
tt = timetable(dt, (1:10).')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by