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 Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by