Update table from columns of another table

4 vues (au cours des 30 derniers jours)
Fabio
Fabio le 21 Déc 2021
Commenté : Fabio le 21 Déc 2021
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

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Déc 2021
Avars = A.Properties.VariableNames;
Bvars = B.Properties.VariableNames;
BnotA = setdiff(Bvars, Avars);
Atab = [Atab, B(:,BnotA)];
  3 commentaires
Walter Roberson
Walter Roberson le 21 Déc 2021
Perhaps you want innerjoin() based upon rowname
Fabio
Fabio le 21 Déc 2021
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by