How concatenate two tables in MATLAB?

조회 수: 794 (최근 30일)
Adriano
Adriano 2016년 11월 19일
댓글: Douglas Novaes 2022년 9월 12일
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
Ravi Raj Pareek
Ravi Raj Pareek 2021년 3월 19일
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

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

채택된 답변

Peter Perkins
Peter Perkins 2016년 11월 23일
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
Peter Perkins
Peter Perkins 2020년 4월 30일
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 2022년 9월 12일
Perfect! Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by