Finding weekly mean of temperature data

조회 수: 3 (최근 30일)
Chika Ugwuodo
Chika Ugwuodo 2021년 2월 11일
댓글: Star Strider 2021년 2월 11일
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.

채택된 답변

Star Strider
Star Strider 2021년 2월 11일
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
Chika Ugwuodo
Chika Ugwuodo 2021년 2월 11일
I think this worked perfectly fine. Thank you so much. Apparently, there is a lot you can do with the table feature of Matlab.
Star Strider
Star Strider 2021년 2월 11일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by