Azzera filtri
Azzera filtri

Merge two columns of same table into one

31 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Akira Agata
Akira Agata il 13 Apr 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);

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by