How can I resample data with multiple time column?

5 ビュー (過去 30 日間)
Anak Agung Adhi Dermawan
Anak Agung Adhi Dermawan 2022 年 8 月 8 日
コメント済み: Star Strider 2022 年 8 月 8 日
19 1 1 0 0 0 1009.4 28.9 71.0 0.0 0.0 0.0 0.0
19 1 1 0 0 30 1009.4 28.8 71.0 0.0 0.0 0.0 0.0
19 1 1 0 1 0 1009.4 28.8 70.9 0.0 0.0 0.0 0.0
19 1 1 0 1 30 1009.3 28.8 70.9 0.0 0.0 0.0 0.0
19 1 1 0 2 0 1009.3 28.8 71.0 0.0 0.0 0.0 0.0
Dear matlab experts, I have a time series data. the first six column from the left are time value with YY:MM:DD:HH:MM:SS with space delimited format. I want to resample all value from secondly to daily. Do I need to convert time's column into timetable?

採用された回答

Star Strider
Star Strider 2022 年 8 月 8 日
One approach —
M = [ 19 1 1 0 0 0 1009.4 28.9 71.0 0.0 0.0 0.0 0.0
19 1 1 0 0 30 1009.4 28.8 71.0 0.0 0.0 0.0 0.0
19 1 1 0 1 0 1009.4 28.8 70.9 0.0 0.0 0.0 0.0
19 1 1 0 1 30 1009.3 28.8 70.9 0.0 0.0 0.0 0.0
19 1 1 0 2 0 1009.3 28.8 71.0 0.0 0.0 0.0 0.0];
M(:,1) = M(:,1)+2000;
T1 = array2table(M(:,7:end));
DT = datetime(M(:,1:6));
T1 = addvars(T1,DT,'before','Var1')
T1 = 5×8 table
DT Var1 Var2 Var3 Var4 Var5 Var6 Var7 ____________________ ______ ____ ____ ____ ____ ____ ____ 01-Jan-2019 00:00:00 1009.4 28.9 71 0 0 0 0 01-Jan-2019 00:00:30 1009.4 28.8 71 0 0 0 0 01-Jan-2019 00:01:00 1009.4 28.8 70.9 0 0 0 0 01-Jan-2019 00:01:30 1009.3 28.8 70.9 0 0 0 0 01-Jan-2019 00:02:00 1009.3 28.8 71 0 0 0 0
TT1 = table2timetable(T1)
TT1 = 5×7 timetable
DT Var1 Var2 Var3 Var4 Var5 Var6 Var7 ____________________ ______ ____ ____ ____ ____ ____ ____ 01-Jan-2019 00:00:00 1009.4 28.9 71 0 0 0 0 01-Jan-2019 00:00:30 1009.4 28.8 71 0 0 0 0 01-Jan-2019 00:01:00 1009.4 28.8 70.9 0 0 0 0 01-Jan-2019 00:01:30 1009.3 28.8 70.9 0 0 0 0 01-Jan-2019 00:02:00 1009.3 28.8 71 0 0 0 0
TT1rt = retime(TT1,'daily')
TT1rt = 2×7 timetable
DT Var1 Var2 Var3 Var4 Var5 Var6 Var7 ___________ ______ ____ ____ ____ ____ ____ ____ 01-Jan-2019 1009.4 28.9 71 0 0 0 0 02-Jan-2019 NaN NaN NaN NaN NaN NaN NaN
For this approach, use the readmatrix funciton to import the matrix.
.
  2 件のコメント
Star Strider
Star Strider 2022 年 8 月 8 日
As always, my pleasure!

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

その他の回答 (0 件)

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by