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

42 ビュー (過去 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 Center および File ExchangeTime Series Events についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by