How concatenate two tables in MATLAB?

790 vues (au cours des 30 derniers jours)
Adriano
Adriano le 19 Nov 2016
Commenté : Douglas Novaes le 12 Sep 2022
I have two tables with no variables in common, with the same number of rows and with different number of columns. For example:
Age Height
___ ______
38 71
43 69
and the table:
Weight Blood
______ ______
176 124
163 109
How can I get:
Age Height Weight Blood
___ ______ ______ _____
38 71 176 124
43 69 163 109
Thanks!
  1 commentaire
Ravi Raj Pareek
Ravi Raj Pareek le 19 Mar 2021
use below command and check if it works:
T = join(Tleft,Tright)
where Tleft is, table with Age and height column
and Tright is, table with weight and blood

Connectez-vous pour commenter.

Réponse acceptée

Peter Perkins
Peter Perkins le 23 Nov 2016
Adriano, to horizontally concatenate anything in MATLAB, you would probably just use square brackets, right? Such as AB = [A B]. Same for tables. cat and horzcat provide a functional form of that, but the standard MATLAB way is brackets.
  3 commentaires
Peter Perkins
Peter Perkins le 30 Avr 2020
Horizontal concatenation of tables will not merge variables. You need to say exactly what you started from and what you did.
Douglas Novaes
Douglas Novaes le 12 Sep 2022
Perfect! Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables 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