how to change data from 10 minutes to hour?

5 ビュー (過去 30 日間)
Jan Risn
Jan Risn 2019 年 5 月 8 日
コメント済み: Jan Risn 2019 年 7 月 8 日
I have data
x =
01/02/2015 02:20 4
02/02/2015 2:30 2
01/02/2015 02:50 0
01/02/2015 08:50 8
01/02/2015 03:00 7
01/02/2015 03:10 9
02/02/2015 3:30 4
02/02/2015 3:40 6
02/02/2015 03:50 8
...
the first step I want to normalize starts from the initial hour (2:00)
and generate data per 10 minutes with empty data filled with Nan
the second step I want to change it to average data per hour ... so that i get hourly data on each date ...
I have tried many times but this doesn't work ..
I thank all those who gave advice and were kind enough to help me.
  2 件のコメント
Jan Risn
Jan Risn 2019 年 5 月 8 日
01/02/2015 02:20 4
02/02/2015 2:30 2
01/02/2015 02:50 0
01/02/2015 08:50 8
01/02/2015 03:00 7
01/02/2015 03:10 9
02/02/2015 3:30 4
02/02/2015 3:40 6
02/02/2015 03:50 8
KSSV
KSSV 2019 年 5 月 8 日
Read about interp1.

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 5 月 8 日
編集済み: Andrei Bobrov 2019 年 5 月 8 日
In R2016b:
T = readtable('data.txt','ReadVariableNames',false,'Format','%q %q %f');
TT = sortrows(timetable(T.Var3,'RowTimes',...
datetime(strcat(T.Var1,'_',T.Var2),'I','dd/MM/uuuu_HH:mm')));
dt = dateshift(TT.Time(1),'start','hour'):...
minutes(10):dateshift(TT.Time(end),'end','hour');
TT1 = retime(TT,dt);% data per 10 minutes
TT2 = retime(TT,'hourly','mean');% average data per hour
  1 件のコメント
Jan Risn
Jan Risn 2019 年 7 月 8 日
thank you for the advice given. but I use matlab 2014a so there is no retime function.
can you help me improve the program script that I have created. I feel difficulties with the accumulation function.
times = record;
dn = datenum(times);
min_time = min(dn);
min_time_dv = datevec(min_time);
min_time_dv(5) = floor(min_time_dv(5) / 10) * 10;
first_slot_dn = datenum(min_time_dv);
max_time = max(dn);
max_time_dv = datevec(max_time);
max_time_dv(5) = floor(max_time_dv(5) / 10) * 10;
last_slot_dn = datenum(max_time_dv);
ten_mins_as_days = 1 / (24 * 60/10);
%%%%% get time per 10 minutes
slot_dns = first_slot_dn : ten_mins_as_days : last_slot_dn;
slot_ds = datestr(slot_dns);
times_minutes = [cellstr(slot_ds(1:end,:))];
slot_ds = datestr(slot_dns);
[~, slot_idx] = histc(dn, slot_dns);
%%% mean RR
mean_RR = accumarray(slot_idx, RR(:), [length(slot_dns)-1,1], @mean, nan);
output = [cellstr(slot_ds(1:end-1,:)), num2cell(mean_RR)];
and display results :
Error using accumarray
First input SUBS and third input SZ must satisfy ALL(MAX(SUBS)<=SZ).
the data I want per 10 minutes and generate data per 10 minutes with empty data filled with Nan
can you fix my akumarray program? I don't understand using this function. I thank you for giving advice and good enough to help me.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by