필터 지우기
필터 지우기

How to find the transition for datetime data?

조회 수: 4 (최근 30일)
Kasih Ditaningtyas Sari Pratiwi
Kasih Ditaningtyas Sari Pratiwi 2017년 11월 18일
댓글: Peter Perkins 2017년 11월 20일
Hi I have a question about how to find the transition for datetime data. I have a time series data and I want to detect the start transition and end transition. I use this following code:
changingdate = rainanalysis{:,'DatumUhrzeit'} >= 1 ;
% use false as logical vector to determine transition. With function diff,
% transitions from false (0) to true (1) will be 1 and transitions from true
% to false will be -1. This will be 1 at the start of a dry period and -1 after the end
datetransitions = diff([false; changingdate; false]);
datestarts = find(datetransitions == 1);
dateends = find(datetransitions == -1) -1;
However I got an error "Comparison is not defined between datetime and double arrays." I attach also the time series table and the picture contain error message here. Thank you for your help.

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 18일
changingdate = diff(rainanalysis{:,'DatumUhrzeit'}) >= 1 ;
  댓글 수: 6
Kasih Ditaningtyas Sari Pratiwi
Kasih Ditaningtyas Sari Pratiwi 2017년 11월 19일
Thank you Walter!
Peter Perkins
Peter Perkins 2017년 11월 20일
Walter's solutions are correct, but I might suggest substituting caldays(1) for 1, for readability.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by