Merging timeseries tables with different time values

17 views (last 30 days)
I want to merge 2 time series tables (data attached). table1 has high frequency data (every 30 minutes). table2 has each day sunrise sunset data. I want to add the sunrise/sunset data to Table 1 such that I get the expected outcome. Because table 1 has every 30 minutes data, I will have to add the same data from table two 48 times in table1. I am having trouble writing the script becasue I am new to matlab. Please help.
Ecpected outcome:
Datetime Year DoY NEE Sunrise Sunset
20090101000000 2009 1 0.2345 736 1746
20090101003000 2009 1 1.2345 736 1746
20090101010000 2009 1 1.2455 736 1746
.......
....
20090102000000 2009 2 1.2455 737 1747
20090102000000 2009 2 1.2455 737 1747
  2 Comments
dpb
dpb on 16 Aug 2022
Just like it's hard for you to type in data by hand, it's a pain for us to have to build trial datasets to illustrate code.
Attach .mat file which contains representative sample of each table.
Benju Baniya
Benju Baniya on 16 Aug 2022
Hi, I just added the data. Sorry about not adding it earlier.

Sign in to comment.

Answers (1)

Rohit
Rohit on 23 Aug 2022
Hi,
As per my understanding the "innerjoin" function can help to merge the tables. Please refer to command mentioned below that will merge the above tables in the required manner.
>> T = innerjoin(table2,table1);
It will map the "Sunrise" and "Sunset" value for every day in "table2" to each 30min data in "table1" for the corresponding day.
For more information, you can refer to the below documentation of "innerjoin" function.

Categories

Find more on Earth and Planetary Science in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!