필터 지우기
필터 지우기

How to concatenate two columns in one table into one column?

조회 수: 98 (최근 30일)
JFz
JFz 2015년 8월 26일
댓글: Peter Jarosi 2019년 7월 12일
Hi,
I have a table of 5 columns with strings, I would like to concatenate the two columns by a "_" and make them into one column.
Table A:
var1 var2 var3 var4 var5 ABC 123 aaa bbb ccc EFG 345 ddd eee fff into B: var1 ABC_123 EFG_345
How to do that?
Thanks.
Jennifer
  댓글 수: 1
JFz
JFz 2015년 8월 26일
In addition, in the var2, there are some string like 'N/A'. I want to replace 'N/A' by just nothing ''.
Thanks for any help.
Jennifer

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

채택된 답변

JFz
JFz 2015년 8월 28일
Actually I did it with t.Var1 = strcat(t.Var1, '_', t.Var2)

추가 답변 (1개)

Varun Bhaskar
Varun Bhaskar 2015년 8월 28일
Hi,
It is not possible to concatenate two columns after the table has been constructed. You can concatenate the two columns prior to constructing the table using the 'strcat' function.
  댓글 수: 1
Peter Jarosi
Peter Jarosi 2019년 7월 12일
Eh,
It's not true. I tried JFz's idea for tables already been constructed. It works! At least in Matlab 2016a or later versions.

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by