Adding new columns in a Table?

조회 수: 29 (최근 30일)
wesleynotwise
wesleynotwise 2017년 6월 9일
댓글: wesleynotwise 2017년 6월 20일
I think this should be quite simple, but somehow I couldn't find the solution online.
I have two Tables, eg: Table1 and Table2. How to add let say two columns from Table 2 to Table 1.
I have tried this, but it does not work as the two input must be in a table form.
T1 = [T1 T2.ColumnA T2.ColumnB]
  댓글 수: 2
Peter Perkins
Peter Perkins 2017년 6월 19일
The problem with this is that you're trying to concatenate a table with two doubles (I'm guessing). As Walter shows, you need to concatenate tables.
wesleynotwise
wesleynotwise 2017년 6월 20일
Hi Peter. Yes, you are right, the columns are doubles. Walter's answer works :)

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 6월 10일
T1 = [T1, T2(:,{'ColumnA', 'ColumnB'})]
Note: this is only permitted if T1 does not already have variables with the same name.
  댓글 수: 1
wesleynotwise
wesleynotwise 2017년 6월 15일
Sorry for my late response to your answer. The code works brilliantly. Thank you.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by