필터 지우기
필터 지우기

Ismember as a condition?

조회 수: 1 (최근 30일)
Daphne PARLIARI
Daphne PARLIARI 2020년 1월 30일
댓글: Daphne PARLIARI 2020년 1월 30일
Hello guys.
I am trying to achieve something easy I think, but I don't know the correct way.
I have two tables, let's say WRF and Obs, that contain hourly values of several variables. What I want to do is calculate things and produce graphs, for the dates that both tables have data.
Eg, WRF contains data from 1/7/2019 to 30/9/2019 and Obs from 31/3/2019 to 30/9/2019.
I tried
ismatch = ismember(Obs.Hourly_DATE, WRF.Date);
which returns 0s kai 1s. How do I take one step further and use the 1s to calculate the things I want?
Thank you in advance!
  댓글 수: 4
Mohammad Sami
Mohammad Sami 2020년 1월 30일
편집: Mohammad Sami 2020년 1월 30일
Ok the innerjoin should then correctly merge the two tables together on the common datetime values. Do verify the newtable created before using it further.
Daphne PARLIARI
Daphne PARLIARI 2020년 1월 30일
편집: Daphne PARLIARI 2020년 1월 30일
Something goes wrong... Attached please find the Obs table, the WRF table and newtable.
Newtable is far too long. I think the problem is that I have to consider columns Time, also (for both tables, WRF and Obs).

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

채택된 답변

Mohammad Sami
Mohammad Sami 2020년 1월 30일
Yes needed to combine with the time column.
load Obs.mat
load WRF.mat
WRF_Data.Date = WRF_Data.Date + duration(hour(WRF_Data.Time),minute(WRF_Data.Time),0)
Obs_Data.Hourly_DATE + duration(string(Obs_Data.Time),'InputFormat','hh:mm');
newtable = innerjoin(Obs_Data,WRF_Data,'LeftKeys','Hourly_DATE','RightKeys','Date');
  댓글 수: 2
Daphne PARLIARI
Daphne PARLIARI 2020년 1월 30일
Works fine with a mistake though:
In newtable, column Time_WRF_Data is in datetime format and it appears 00:00 in all rows....
Daphne PARLIARI
Daphne PARLIARI 2020년 1월 30일
The mistake I mentioned above is easily corrected this way:
WRF_Data.Date = WRF_Data.Date + duration(hour(WRF_Data.Time),minute(WRF_Data.Time),0);
Obs_Data.Hourly_DATE = Obs_Data.Hourly_DATE + duration(string(Obs_Data.Time),'InputFormat','hh:mm');
All_Data = innerjoin(Obs_Data,WRF_Data,'LeftKeys','Hourly_DATE','RightKeys','Date');

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by