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

조회 수: 6 (최근 30일)
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

채택된 답변

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

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by