Filter löschen
Filter löschen

Hi All, I have several days worth of time stamped data. Unfortunatly the date has not been provided. How can I convert the time to datetime and increase the date by one day when the time passes 00:00:00? Thankyou

1 Ansicht (letzte 30 Tage)
Sample of Data at 'change of day'
23:59:57,0.0010465
23:59:58,0.0010821
23:59:59,0.0010785
00:00:00,0.0010473
00:00:02,0.0008437
00:00:03,0.0011811
  2 Kommentare
dpb
dpb am 3 Dez. 2018
Do you know the start date (from the file timestamp, maybe, or other means)?
Is time of day of significance or could you do just as well with a duration timeseries as long as it reflects proper sampling interval?
Joshua Firmin
Joshua Firmin am 3 Dez. 2018
The Date isn't important in itself. I need it to graph in the correct order alongside other data

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

dpb
dpb am 3 Dez. 2018
tsd=readtable('tsd.txt');
tsd.Var1=datetime(tsd.Var1);
du=[duration(0,0,0);diff(tsd.Var1)];
ix=find(du<0);
tsd.Var1(ix:end)=tsd.Var1(ix:end)+1;
>> tsd =
6×2 table
Var1 Var2
____________________ _________
03-Dec-2018 23:59:57 0.0010465
03-Dec-2018 23:59:58 0.0010821
03-Dec-2018 23:59:59 0.0010785
04-Dec-2018 00:00:00 0.0010473
04-Dec-2018 00:00:02 0.0008437
04-Dec-2018 00:00:03 0.0011811
>>
Rinse and repeat...a loop or arrayfun over length of ix for the locations of negative values will be simplest to code methinks. One could also find the breaks between and add the successive number of days and build that vector of corrections.
  2 Kommentare
dpb
dpb am 3 Dez. 2018
As you note, datetime will default to current date lacking info; you can always specify a specific date if needs be to reflect the actual time of the acquisition.
Or, of course, if isn't important at all about time-of-day, then you can just subtract the first element and have simply zero-based duration instead.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by