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

41 Ansichten (letzte 30 Tage)
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{:});

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 18 Okt. 2018
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).')

Weitere Antworten (0)

Kategorien

Mehr zu Time Series Events finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by