필터 지우기
필터 지우기

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 (최근 30일)
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
dpb
dpb 2018년 12월 3일
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 2018년 12월 3일
The Date isn't important in itself. I need it to graph in the correct order alongside other data

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2018년 12월 3일
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
dpb
dpb 2018년 12월 3일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by