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

39 vues (au cours des 30 derniers jours)
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{:});

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Time Series Events dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by