Filter löschen
Filter löschen

Merge two columns of same table into one

31 Ansichten (letzte 30 Tage)
Adnan Habib
Adnan Habib am 13 Apr. 2020
Kommentiert: Adnan Habib am 13 Apr. 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?

Akzeptierte Antwort

Akira Agata
Akira Agata am 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);

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by