MATLAB Answers

Jan Risn
0

how to change data from 10 minutes to hour?

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
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
2019 年 5 月 8 日
Read about interp1.

サインイン to comment.

1 件の回答

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
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.

サインイン to comment.



Translated by