How calculate daily, monthly, seasonally mean average and std?

12 ビュー (過去 30 日間)
Aries Dwi Siswanto
Aries Dwi Siswanto 2020 年 5 月 2 日
Hi everyone,
I'm a new beginner in matlab.
I want to calculate daily, monthly, and seasonally average for time series data.
The first column is date, second column is month, 3rd column is year, 4th column is hour, 5th column is minutes, 6th column is second, and 7th until the end of column is my data.
Could anyone help me how to calculate in daily, monthly, and seasonally average?
Thank you for your help.

採用された回答

Akira Agata
Akira Agata 2020 年 5 月 7 日
I would recommend storing the data as timetable variable, and applying retime function.
The following is an example:
% Load data file
load('Date1Time1Data1.mat');
% Create datetime array
Time = datetime(...
Date1Time1Data1(:,3),Date1Time1Data1(:,2),Date1Time1Data1(:,1),...
Date1Time1Data1(:,4),Date1Time1Data1(:,5),Date1Time1Data1(:,6));
% Arrange data array to timetable variable
TT = array2timetable(Date1Time1Data1(:,7:end),'RowTimes',Time);
% Example1: daily average
TT_da = retime(TT,'daily','mean');
% Example2: montly std
TT_ms = retime(TT,'monthly',@std);
  1 件のコメント
Aries Dwi Siswanto
Aries Dwi Siswanto 2020 年 5 月 7 日
Dear Akira Agata,
Thank you very much for your help,
That is perfectly work.

サインインしてコメントする。

その他の回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 5 月 2 日
編集済み: KALYAN ACHARJYA 2020 年 5 月 2 日
%Load the mat file
%Monthly
len_month=length(unique(data(:,2))); or %use size(data(:,2),1)
monthly_data=sum(data(:,end))/len_month;
Just do the unique on the respective columns and devide by sum(data(:,end)) by the respective length
  1 件のコメント
Aries Dwi Siswanto
Aries Dwi Siswanto 2020 年 5 月 2 日
Hi Kalyan Acharjya,
Thank you for your help,
I've already trying your code, the result show the amount of monthly data.
monthly_data =
1.5468e+05
I want to calculate the monthly average (also daily and seasonally).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTimetables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by