MATLAB: How to calculate Daily mean and monthly mean from hourly data meanmonthly mean I have hourly data for 5years continuasly and I would like to calculate daily mean and montly mean. Sample data file attached Best Answer I would recommend the following steps:Import the data fileArrange the data and create timetable variableApply retime funciton to obtain daily/monthly averageThe following is an example:% Read the data fileopts = detectImportOptions('test_pog.txt');T = readtable('test_pog.txt',opts);% Make a datetime vectorTime = datetime(T{:,1},'InputFormat','yyyy.MM.dd.');Time.Hour = T{:,2};% Add the datetime vector and remove the 1st&2nd columnsT.Time = Time;T(:,1:2) = [];% Convert to timetableTT = table2timetable(T);% Apply retime function to obtain daily/monthly meanTTdailyMean = retime(TT,'daily','mean');TTmonthlyMean = retime(TT,'monthly','mean'); Related SolutionsMATLAB: Mean A=rand(76,5); m=mean(A,2); MATLAB: Convert date to datetime t = datetime(DateStrings,'InputFormat','dd/MM/yyyy'); Related QuestionFinding meanTimetable Monthly Average over Many YearsHow calculate daily, monthly, seasonally mean average and stdHow to arrenge timeseries data
Best Answer