Merge two columns of same table into one

23 ビュー (過去 30 日間)
Adnan Habib
Adnan Habib 2020 年 4 月 13 日
コメント済み: Adnan Habib 2020 年 4 月 13 日
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?

採用された回答

Akira Agata
Akira Agata 2020 年 4 月 13 日
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);
  1 件のコメント
Adnan Habib
Adnan Habib 2020 年 4 月 13 日
This worked nicely! Thank you very much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by