Update table from columns of another table

조회 수: 4 (최근 30일)
Fabio
Fabio 2021년 12월 21일
댓글: Fabio 2021년 12월 21일
Hello everyone,
I have two tables, “Atab” and “Btab”, and I would like to update “Atab” by adding all the columns (variables) and their respective values that are in “Btab” but not in “Atab” (meaning columns “Trans” and “Det”).
See in attached “Atab”, “Btab” and the expected “Output” in jpeg files.
Thanks in advance

채택된 답변

Walter Roberson
Walter Roberson 2021년 12월 21일
Avars = A.Properties.VariableNames;
Bvars = B.Properties.VariableNames;
BnotA = setdiff(Bvars, Avars);
Atab = [Atab, B(:,BnotA)];
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 12월 21일
Perhaps you want innerjoin() based upon rowname
Fabio
Fabio 2021년 12월 21일
Yes I would like to innerjoy, but based on the example in the link, I would like that “T” shows as well rows “1” with “Var2” empty and rows “7” and “9” with “Var1” empty.

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

추가 답변 (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