MATLAB: I have an hourly meteorological data screenshot attached which i need to convert to average daily data. Since I have a long period of data it is difficult to do it in excel. If anyone knows how to code it in matlab pls let me know

hourly to daily rainfallrainfall data

Best Answer

T = readtable('your_xls_file.xls');
t = datetime(strcat(T{:,2},'_',T{:,1}),'i','MM/dd/uuuu_HH:mm');
TT = table2timetable(T(:,3:end),'RowTimes',t);
E = regexp(TT{:,end},'\d+','match');
E = str2double(cat(1,E{:}));
tt = duration(E(:,1),E(:,2),0);
TT = [TT(:,1:end-1),table(tt,'v',TT.Properties.VariableNames(end))];
TTout = retime(TT,'daily','mean');
TTout = TTout(all(~isnan(TTout{:,:}),2),:);
or
T = readtable('your_xls_file.xls');
t = datetime(T{:,2});
A = regexp(T{:,end},'\d+','match');
A = str2double(cat(1,A{:}));
tt = duration(A(:,1),A(:,2),0);
TT = table2timetable([T(:,3:end-1),table(tt,'v',T.Properties.VariableNames(end))],'RowTimes',t);
TTout = varfun(@mean,TT,'GroupingVariables','Time');