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

42 visualizaciones (últimos 30 días)
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{:});

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 18 de Oct. de 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).')

Más respuestas (0)

Categorías

Más información sobre Time Series Events en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by