How to average seconds data to minutes data?

I have a set of data with me. I want to average this seconds data into minutes average data.
I used following code, but I didn't get.
Z=xlsread('V.csv',-1);
nhours=1;
Ts=1;
data=[Z];
meanT=60;
data=rand(3600,1);
matrix=reshape(data,3600/Ts,nhours);
out=mean(matrix(1:meanT/Ts,:))
I want help and its urgent. Find the data file attached.

2 件のコメント

Guillaume
Guillaume 2017 年 12 月 11 日
Well, for something urgent, you certainly haven't made much of an effort. Do you even understand the code you've written, particularly the line
data = rand(3600, 1)
where you replace what you've just read from the file by one column of random data?
Kraunchaa
Kraunchaa 2017 年 12 月 11 日
Yes sir. I haven't done coding in my entire life. Now I started with it from yesterday evening. Suddenly need came. I am working on learning this slowly slowly. Thank you sir.

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

 採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 12 月 11 日
編集済み: Andrei Bobrov 2017 年 12 月 11 日

1 投票

T = readtable('V.csv');
T.Var1 = datetime(T.Var1,'f','HH:mm:SS');
TT = table2timetable(T);
TT_out = retime(TT,'minutely','mean');
or
T = readtable('V.csv');
T.Var1 = datetime(T.Var1);
[~,~,~,hh,mm] = datevec(T.Var1);
[~,~,T.g] = unique([hh,mm],'rows');
T_out = varfun(@mean,T,'gr','g');
T_out = T_out(:,3:end);

2 件のコメント

KL
KL 2017 年 12 月 11 日
編集済み: KL 2017 年 12 月 11 日
+1! @Kraunchaa: Just to mention, works on versions 16b or above. For the older ones please use table, datevec along with accumarray. There are examples on the forum already.
Kraunchaa
Kraunchaa 2017 年 12 月 19 日
thank you sir...

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

その他の回答 (1 件)

Guillaume
Guillaume 2017 年 12 月 11 日

0 投票

Honestly, I doesn't look like you've made much effort. Nearly none of the line you've written make any sense. Particularly the one where you replace the whole of the content of the file you've read by random data.
It's very easy to do with timetables:
tt = table2timetable(readtable('V.csv', 'Format', '%{HH:mm:ss}D%f'));
tt_minutely = retime(tt, 'minutely', 'mean')

カテゴリ

ヘルプ センター および File ExchangeTime Series Events についてさらに検索

質問済み:

2017 年 12 月 11 日

コメント済み:

2017 年 12 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by