Merge two columns of same table into one

23 visualizaciones (últimos 30 días)
Adnan Habib
Adnan Habib el 13 de Abr. de 2020
Comentada: Adnan Habib el 13 de Abr. de 2020
Hi,
I have a table with 3 columns like the following:
A B C
'4618' '1193' 3
'9810' '1224' 1
'7810' '27845' 1
'6324' '1627' 6
'8954' '1678' 1
'9629' '2061' 1
I have only shown a small portion of the table, actually it is a 3079X3 table. A and B are cells and C is a double. I want the table to look like this:
AB C
'46181193' 3
'98101224' 1
'781027845' 1
'63241627' 6
'89541678' 1
'96292061' 1
I have tried using horzcat but it didn't work. Can someone please help me out with the code?

Respuesta aceptada

Akira Agata
Akira Agata el 13 de Abr. de 2020
Assuming columns A and B are cell array of characters, how about the following?
% Sample input table
A = {'123';'234';'345'};
B = {'1111';'2222';'3333'};
C = [1;2;3];
T1 = table(A,B,C);
% Create output table
AB = strcat(T1.A,T1.B);
T2 = table(AB,C);

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by