Join table with different lengths

Hi!
I have 2 types of tables.
In the first type of table "Country", I have stored a data for each country (Var2, in the example screenshoot):
The second type of table "Grouped_Weight_position{i}", has the follow form:
I would join in the second type of table (Grouped_Weight_position{i}) the data (Var2) from the first type of table (Country) only if in the second type of table exist the same country. Would anyone know how to show me a way?
Thank at all.

답변 (1개)

Matt J
Matt J 2020년 5월 21일

2 개 추천

innerjoin(Grouped_Weight_position{i},Country)

댓글 수: 4

Mario Diaco
Mario Diaco 2020년 5월 21일
Really easy! Thanks!
Matt J
Matt J 2020년 5월 21일
You're welcome, but please Accept-click the answer, since it seems to have fulfilled what you were looking for.
John Navarro
John Navarro 2020년 6월 10일
Thanks Matt J.
I have a similar case, but I want combine all "Countries" but I requiere it to create a NaN value (or zero) for those countries that are not in both tables.
In other words, i need to know which countries have all the information and which one do not.
Any idea? Thanks
John Navarro
John Navarro 2020년 6월 10일
편집: John Navarro 2020년 6월 10일
It just make it works by using
C = outerjoin(A,B,'Keys',{'Country'},'MergeKeys',true)
% Where A and B are the corresponding Tables to merge.
BUT, It wont work if you use the automatic code that is generated by the Task option in the live script
C = outerjoin(A,B,'Type','left','Keys',{'Country'},'MergeKeys',true)

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2020년 5월 21일

편집:

2020년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by