Finding weekly mean of temperature data
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chika Ugwuodo
am 11 Feb. 2021
Kommentiert: Star Strider
am 11 Feb. 2021
I have temperature data with day, month, and year columns supplied as integer values. How do I obtain the weekly temperature average. I have no idea how to do this.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 11 Feb. 2021
Use an appropriate function to read the file (readmatrix, or a similar appropriate function), then try this prototype code with your data:
Y = ones(31,1)*2021; % Create Original Year Data
M = ones(31,1); % Create Original Month Data
D = (1:31).'; % Create Original Day Data
Date = datetime([Y,M,D]); % Convert To ‘datetime’
Temperature = 20 + 5*sin(2*pi*D/31)+randn(size(D))/10; % Create ‘Temperature’ Vector
T1 = table(Date,Temperature); % Create Table
TT1 = table2timetable(T1); % Convert To ‘timetable’
TT2 = retime(TT1,'weekly','mean'); % Timetable With Weekly Averages
Make appropriate changes to work with the available data.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time 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!