Clear Filters
Clear Filters

Add monthly value from one table to daily data in another table by matching month-year

1 view (last 30 days)
Hi, I have two tables
Table 1 are daily data and Table 2 are monthly data. I am trying to add the monthly value in Table 2 to all the days of that month in Table 1. I have been looking for hours now at examples on this forum using datetime etc to try and match the month and year, but cannot figure it out (I am a newbie). Basically I need to add 4.1193 (from Table 1) to 1-Apr-2013 to 30-Apr-2013 in Table 1, and then 4.8593 (from Table 2) to 1-May-2013 to 31-May-2013 in Table 1 etc. It's a common 'delta change' method so I know there's probably very simple code out there somewhere...
In summary, add Delta_MM for month X year X (Table 2) to all the TAIR values for the days/rows in that same month-year in Table 1. The end result will be a new daily timeseries of 2466 rows.
I had resorted to just going through and copy - pasting it month-by-month (pathetic, I know..), but I need to do this a few times with more data later so I realised I need help...
Can anybody help me please?
Thank you!
Table 1 (2466 x 2) Table 2 (360 x 2)
DateTime TAIR DateTime Delta_MM
01-Apr-2013 -7.5 01-Apr-2013 4.1193
02-Apr-2013 -2.9 01-May-2013 4.8593
03-Apr-2013 0.3 01-June-2013 -0.3856
etc etc etc etc
31-Dec-2019 -1.8 31-Dec-2019 -6.0221

Accepted Answer

Star Strider
Star Strider on 15 Jan 2023
I do not have a thorough understanding of what you want to do.
One option could be join, and another could be synchronize.
  4 Comments
JAT
JAT on 16 Jan 2023
Yes! Worked perfectly to match that up thank you very much!
TTsync = synchronize(TTAir, TTDMB, 'first','previous');

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!