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

123 vues (au cours des 30 derniers jours)
JFz
JFz le 26 Août 2015
Commenté : Peter Jarosi le 12 Juil 2019
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 commentaire
JFz
JFz le 26 Août 2015
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

Connectez-vous pour commenter.

Réponse acceptée

JFz
JFz le 28 Août 2015
Actually I did it with t.Var1 = strcat(t.Var1, '_', t.Var2)

Plus de réponses (1)

Varun Bhaskar
Varun Bhaskar le 28 Août 2015
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 commentaire
Peter Jarosi
Peter Jarosi le 12 Juil 2019
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by