フィルターのクリア

Averaging and summing parts of a column based on date

2 ビュー (過去 30 日間)
Wendy Cameron
Wendy Cameron 2019 年 1 月 24 日
コメント済み: Wendy Cameron 2019 年 1 月 30 日
Greetings Matlab community
I have some very large data sets and I am wanting to sum and average parts of a table column based on the date. I have multiple readings of e.g. temperature for a given date and want to both sum and average these for each given date and get a corresponding table with the results.
A VERY cut down version of the data is attached and I want to get a result that has three columns - the date, the average Maxium temperature and the Total max temp for each date.
Much appreciated

採用された回答

per isakson
per isakson 2019 年 1 月 25 日
編集済み: per isakson 2019 年 1 月 25 日
Ten hours without an answer. Here is the result from my first experiment with timetable. See retime Resample or aggregate data in timetable, and resolve duplicate or irregular times
%%
T = readtable('Matlab question.xlsx');
%%
TT = table2timetable( T, 'rowTimes','Var1' );
%%
dm = retime( TT, 'daily','mean' );
%%
dx = retime( TT, 'daily','max' );
%%
ds = retime( TT, 'daily','sum' );
  1 件のコメント
Wendy Cameron
Wendy Cameron 2019 年 1 月 30 日
Thank you. That works. I am now wondering if one can turn a timetable e.g. dm etc, back to a table?

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2019 年 1 月 25 日
T = readtable('Matlab question.xlsx','Ra','A2:B109','ReadV',0);
out = rowfun(@tempfun,T,'G','Var1',...
'OutputV',...
{'MeanTemp' 'MaxTemp'});
function varargout = tempfun(x)
varargout = {mean(x),max(x)};
end

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by