How to combine columns from large dataset to datetime with correct vector or doublestring?

2 次查看(过去 30 天)
I am trying to combine date and time so that I can plot discharge over time. Year, month, day, and hour (in minutes) are in different columns. I have tried several this including
Date=datetime(dataTable(:,3:5))+hours(data(:,8));
and get errors. For this it says
Input data must be a numeric array, a string array, a cell array containing character vectors, or a char matrix.
Any suggestions?

采纳的回答

Star Strider
Star Strider 2023-11-12
Use curly brackets {} instead of parentheses when referring to numbered table variables —
Date=datetime(dataTable{:,3:5})+hours(dataTable{:,8});
dataTable = table(rand(2,1),rand(2,1),[2023;2023],[11;11],[10;11],rand(2,1),rand(2,1),[11;13])
dataTable = 2×8 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 _______ ________ ____ ____ ____ _______ _______ ____ 0.21309 0.038666 2023 11 10 0.32764 0.77161 11 0.22024 0.052536 2023 11 11 0.70769 0.31238 13
Date=datetime(dataTable{:,3:5})+hours(dataTable{:,8})
Date = 2×1 datetime array
10-Nov-2023 11:00:00 11-Nov-2023 13:00:00
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by