How to remove leap year dates from time series in data

조회 수: 4 (최근 30일)
peter huang
peter huang 2022년 1월 25일
댓글: peter huang 2022년 2월 17일
How to remove leap year(2/29) dates from time series in data
(My time series is hour by hour)
  댓글 수: 3
Rik
Rik 2022년 1월 25일
What did you try? It should be easy enough to test whether a specific datenum or datetime is February 29th.
peter huang
peter huang 2022년 1월 25일
I try many ways However, the data of the 2/29 date could not be successfully removed.
what is specific datenum or datetime ?

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

채택된 답변

Murugan C
Murugan C 2022년 1월 25일
[numDat,txtDat,rawDat] = xlsread('moving_windown_test.xlsx');
leafYecount = 1;
for i1 = 1 : size(rawDat,1)
str_data = num2str(rawDat{i1,1});
f = datetime(str2double(str_data(1:4)),str2double(str_data(5:6)),str2double(str_data(7:end)));
fe = datestr(f,'dd/mm');
if strcmp(fe,'29/02')
disp(['Leaf Year ' datestr(f)]);
leafYe(leafYecount) = i1;
leafYecount = leafYecount + 1;
end
end
rawDat(leafYe',:) = [];
xlswrite('removedLeafYear',rawDat);
  댓글 수: 3
Murugan C
Murugan C 2022년 1월 27일
Please run my code. After that you can open 'removedLeafYear.xlsx' you can see removed leaf year.
Did you run my code.?
peter huang
peter huang 2022년 2월 17일
oh thanks you are solve my problem

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by