Join two tables with the same headers

78 vues (au cours des 30 derniers jours)
Trevor Savage
Trevor Savage le 19 Avr 2016
Commenté : Colin Fulham le 20 Mai 2019
I have two tables created from different sources that have the same headers that I would like to join together. Table one has 10 rows with Headers: A B C D
Table two has 11 rows with Headers: A B C D
I would like to make a combined table with all columns and 21 rows
What do I have to tell MatLab to make it do what I want it to do?

Réponse acceptée

Guillaume
Guillaume le 19 Avr 2016
Modifié(e) : Guillaume le 19 Avr 2016
just vertically concatenate them:
newtable = [table1; table2]; %note the semicolon for vertical concatenation
%or
newtable = vertcat(table1, table2);
  2 commentaires
Caglar
Caglar le 31 Oct 2018
Hello, How would you do it if you were not sure headers were aligned? (for example, first table headers: A B C D, second table headers: B C A D)
Colin Fulham
Colin Fulham le 20 Mai 2019
As long as the Variable names in both tables are the same, Matlab will reorder the second table to match the first before it concatenates them.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Identification 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