How to merge two timetables with different data and time?

Hi everyone, I had a nice and clean time table that I had to extract some sections of it for calculations during different hours of day. For example Jan to May 10 to 14 and 0 to 10 and 14 to 00. Now I have three time tables from the extracted one. I want to merge them again so that I will have one clean timetable with only one column of data rather than 3 columns with NaN (that what I am getting). Also, [T1;T2] is not working and retrns the following error:
All tables in the bracketed expression must have the same number of rows.

댓글 수: 5

If you're trying one of these methods listed in the link below and it isn't working for you, provide more detail including error messages and samples from your table (using head()).
@Adam Danz thank you! I actually read them all and applied some but none are working for my case. So I had huge annual data with 5 minute intervals. I extracted some specific dates and their corresponding value (second column - if you know any easy way for this please let me know) and then I multiplied those values by some other values. Now they are section by section, for example, March 20 to April 13 and then April 14 to Dec 20. I used a concept in that page which literally replaces NaN of one huge timetable with other values in the other timesection but I found it very rudimentary method and I believe there should be other ways that are smarter, more efficient, and less time consuming.
> [T1;T2] is not working and retrns the following error: All tables in the bracketed expression must have the same number of rows.
This is fishy. The example below shows that a vertical concatenation is perfectly fine when the tables have a different number of rows.
Please share
  1. the result of head(T) for each table
  2. the line of code where you're doing the concatenation
  3. the entire error message.
Demo:
T1 = array2timetable((1:3)'.*ones(1,4), 'RowTimes', datetime('today')+(0:2))
T1 = 3x4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 29-Jan-2021 1 1 1 1 30-Jan-2021 2 2 2 2 31-Jan-2021 3 3 3 3
T2 = array2timetable((1:5)'.*ones(1,4), 'RowTimes', datetime('today')+(0:4))
T2 = 5x4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 29-Jan-2021 1 1 1 1 30-Jan-2021 2 2 2 2 31-Jan-2021 3 3 3 3 01-Feb-2021 4 4 4 4 02-Feb-2021 5 5 5 5
T = [T1; T2]
T = 8x4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 29-Jan-2021 1 1 1 1 30-Jan-2021 2 2 2 2 31-Jan-2021 3 3 3 3 29-Jan-2021 1 1 1 1 30-Jan-2021 2 2 2 2 31-Jan-2021 3 3 3 3 01-Feb-2021 4 4 4 4 02-Feb-2021 5 5 5 5
@Adam Danz Hi, could you please post this to the answer so that I can mark it as the answer?
Done. Thanks, Wolfgang.

댓글을 달려면 로그인하십시오.

 채택된 답변

> [T1;T2] is not working and retrns the following error: All tables in the bracketed expression must have the same number of rows.
This is fishy. The example below shows that a vertical concatenation is perfectly fine when the tables have a different number of rows.
Please share
  1. the result of head(T) for each table
  2. the line of code where you're doing the concatenation
  3. the entire error message.
Demo:
T1 = array2timetable((1:3)'.*ones(1,4), 'RowTimes', datetime('today')+(0:2))
T1 = 3x4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 10-Mar-2021 1 1 1 1 11-Mar-2021 2 2 2 2 12-Mar-2021 3 3 3 3
T2 = array2timetable((1:5)'.*ones(1,4), 'RowTimes', datetime('today')+(0:4))
T2 = 5x4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 10-Mar-2021 1 1 1 1 11-Mar-2021 2 2 2 2 12-Mar-2021 3 3 3 3 13-Mar-2021 4 4 4 4 14-Mar-2021 5 5 5 5
T = [T1; T2]
T = 8x4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 10-Mar-2021 1 1 1 1 11-Mar-2021 2 2 2 2 12-Mar-2021 3 3 3 3 10-Mar-2021 1 1 1 1 11-Mar-2021 2 2 2 2 12-Mar-2021 3 3 3 3 13-Mar-2021 4 4 4 4 14-Mar-2021 5 5 5 5

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by