Join two tables with the same headers

조회 수: 105 (최근 30일)
Trevor Savage
Trevor Savage 2016년 4월 19일
댓글: Colin Fulham 2019년 5월 20일
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?

채택된 답변

Guillaume
Guillaume 2016년 4월 19일
편집: Guillaume 2016년 4월 19일
just vertically concatenate them:
newtable = [table1; table2]; %note the semicolon for vertical concatenation
%or
newtable = vertcat(table1, table2);
  댓글 수: 2
Caglar
Caglar 2018년 10월 31일
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 2019년 5월 20일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by