converting table 2 timetable using timeVarName

조회 수: 10 (최근 30일)
Antonino Cataldo
Antonino Cataldo 2021년 2월 7일
댓글: Antonino Cataldo 2021년 2월 7일
Hi,
As the title sugguests I am trying to convert a table (originally from excel) to a time table. I'm trying to use a specific variable for RowTimes. I get the error message "row times must be datetime or duration vector".
How to a "convertor" a specfic variable to a duration vector in my original table or during data import?. Variable I want to use is a simple timestamp in seconds ( a recorder time from data acqusition software).
Thanks

채택된 답변

Steven Lord
Steven Lord 2021년 2월 7일
A = array2table(magic(4))
A = 4x4 table
Var1 Var2 Var3 Var4 ____ ____ ____ ____ 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
T = table2timetable(A, 'RowTimes', seconds(A.Var1))
T = 4x4 timetable
Time Var1 Var2 Var3 Var4 ______ ____ ____ ____ ____ 16 sec 16 2 3 13 5 sec 5 11 10 8 9 sec 9 7 6 12 4 sec 4 14 15 1
You'd probably want to remove Var1 from T if you do this.
T2 = table2timetable(A(:, 2:4), 'RowTimes', seconds(A.Var1))
T2 = 4x3 timetable
Time Var2 Var3 Var4 ______ ____ ____ ____ 16 sec 2 3 13 5 sec 11 10 8 9 sec 7 6 12 4 sec 14 15 1

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by