How to remove leap year(2/29) dates from time series in data
(My time series is hour by hour)

3 commentaires

Just remove that day
What did you try? It should be easy enough to test whether a specific datenum or datetime is February 29th.
I try many ways However, the data of the 2/29 date could not be successfully removed.
what is specific datenum or datetime ?

Connectez-vous pour commenter.

 Réponse acceptée

[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 commentaires

I just looked at the excel file and it still hasn't been removed 2/29 This is how I load the data
code:
filehtm = dir('moving_windown_test.xlsx') ;
for ii = 1 : length(filehtm);
filehtm(ii).name
[num,str,xlsdata] = xlsread(filehtm(ii).name) ; %num數值 str字串
end
time = num(:,1) ;
tide_detrend = num(:,2) ./ 1000 ;
tide = tide_detrend ;
tide_test = tide_detrend;
%% set time
YYYY = fix(time/1000000) ;
MM = mod(fix(time/10000),100) ;
DD = mod(fix(time/100),100) ;
HH = mod(time,100) ;
tt = datenum(YYYY,MM,DD,HH,0,0) ;
%%
t1 = datenum(1961,1,1) : 1/24 : datenum(1966,1,1) ;
Please run my code. After that you can open 'removedLeafYear.xlsx' you can see removed leaf year.
Did you run my code.?
oh thanks you are solve my problem

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by