How to calculate hourly average value for measured Temperature, CO2, RH and Rid in 5 minutes interval
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gadelhag M Omar Mohmed
am 11 Feb. 2021
Kommentiert: Cris LaPierre
am 12 Feb. 2021
Hello all.
Hopfully you all stay well and safe.
I have Temperature, CO2, RH and Rid measured each 5 minutes interval for about 36 days, (from 09/04/2020 to 14/05/2020) about 10080 rows in total. From these data I need to calculate the hourly average value for these measured Temperature, CO2, RH and Rid which means that eventually I must have 24 hourly averaged values per day.
I would appreciate any ideas on the matter!
I have attached the excel file I'm working on.
Regards
0 Kommentare
Akzeptierte Antwort
Walter Mabry
am 11 Feb. 2021
Bearbeitet: Walter Mabry
am 11 Feb. 2021
The loop below breaks up you time stamps into hours and creates a new vector with the mean value for each hour of the provided data.
Temp = data1(:,4);
i = 12:12:840;
for k = 1:length(i)
DailyAvg(k) = mean(Temp((i(k)-11):i(k)));
end
7 Kommentare
Walter Mabry
am 11 Feb. 2021
you are importanting the data as a cell. just import the numbers as an array with out the headings. You could use readmatrix() or just use the import data tool under the home tab
Weitere Antworten (2)
Cris LaPierre
am 11 Feb. 2021
Use groupsummary. I suggest combining your dates and times into a single datetime varlable to make this easier.
opts = detectImportOptions("Gadelhagdata.xlsx","Range",'A:K');
opts = setvartype(opts,"time","duration");
opts = setvaropts(opts,"time","InputFormat","hh:mm:ss");
data = readtable("Gadelhagdata.xlsx",opts);
% combine data and time
data.date = data.date + data.time;
data.time = [];
hrAvg = groupsummary(data,"date","hour","mean")
6 Kommentare
Sean de Wolski
am 11 Feb. 2021
Read it in as a timetable readtimetable then call retime which does exactly what you want.
t = readtimetable('yourfile')
fiveminutemean = retime(t, 'Regular', 'mean', 'TimeStep', minutes(5))
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!