Merging timeseries tables with different time values

14 次查看(过去 30 天)
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 个评论
dpb
dpb 2022-8-16
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 2022-8-16
Hi, I just added the data. Sorry about not adding it earlier.

请先登录,再进行评论。

回答(1 个)

Rohit
Rohit 2022-8-23
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.

类别

Help CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by